領収証発行サービス
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

47 lines
896B

  1. <?php
  2. namespace App\Rules;
  3. use App\Util\KeysConverter;
  4. class ParkingManagementCode extends BaseRule
  5. {
  6. private string $customerCode;
  7. /**
  8. * Create a new rule instance.
  9. *
  10. * @return void
  11. */
  12. public function __construct($customerCode = "")
  13. {
  14. $this->customerCode = $customerCode;
  15. }
  16. public function check($value) : bool
  17. {
  18. if (!is_string($value)) return false;
  19. if (strlen($value) !== 5) return false;
  20. if(strlen($this->customerCode)){
  21. try {
  22. KeysConverter::getTblPark($this->customerCode, $value);
  23. }catch(Exception){
  24. return false;
  25. }
  26. }
  27. return true;
  28. }
  29. /**
  30. * Get the validation error message.
  31. *
  32. * @return string
  33. */
  34. public function message()
  35. {
  36. return '正しくありません';
  37. }
  38. }