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

57 lines
1.5KB

  1. <?php
  2. namespace App\Jobs\Other\Custom\HelloTechno;
  3. use App\Codes\QueueName;
  4. use App\Jobs\BaseJob;
  5. use App\Logic\SMS\SMSManager;
  6. use App\Models\HtCustomParkingName;
  7. use App\Util\Custom\HelloTechno\API;
  8. class CacheParkingName extends BaseJob
  9. {
  10. /**
  11. * Create a new job instance.
  12. *
  13. * @return void
  14. */
  15. public function __construct(
  16. private string $customerCode,
  17. private string $parkingManagementCode
  18. ) {
  19. $this->onQueue(QueueName::JOB->value);
  20. }
  21. /**
  22. * Execute the job.
  23. *
  24. * @return void
  25. */
  26. public function handle(SMSManager $manager)
  27. {
  28. // 顧客情報取得
  29. $customer = collect(API::getCustomers($this->customerCode))
  30. ->where('customer_code', $this->customerCode)
  31. ->firstOrFail();
  32. // 駐車場情報取得
  33. $parking = collect(API::getParkings($this->customerCode, $this->parkingManagementCode))
  34. ->where('parking_management_code', $this->parkingManagementCode)
  35. ->firstOrFail();
  36. // モデル更新
  37. $model = HtCustomParkingName::whereCustomerCode($this->customerCode)
  38. ->whereParkingManagementCode($this->parkingManagementCode)
  39. ->firstOrNew([
  40. HtCustomParkingName::COL_NAME_CUSTOMER_CODE => $this->customerCode,
  41. HtCustomParkingName::COL_NAME_PARKING_MANAGEMENT_CODE => $this->parkingManagementCode,
  42. ]);
  43. $model->customer_name = $customer['name'];
  44. $model->parking_name = $parking['name'];
  45. $model->save();
  46. }
  47. }