|
- <?php
-
- namespace App\Jobs\Other\Custom\HelloTechno;
-
- use App\Codes\QueueName;
- use App\Logic\SMS\SMSManager;
- use App\Models\HtCustomParkingName;
- use App\Models\SMSSendOrder;
- use App\Util\Custom\HelloTechno\API;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Support\Arr;
-
- class CacheParkingName implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(
- private string $customerCode,
- private string $parkingManagementCode
- ) {
- $this->onQueue(QueueName::OTHER->value);
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle(SMSManager $manager)
- {
-
- // 顧客情報取得
- $customer = collect(API::getCustomers($this->customerCode))
- ->where('customer_code', $this->customerCode)
- ->firstOrFail();
- // 駐車場情報取得
- $parking = collect(API::getParkings($this->customerCode, $this->parkingManagementCode))
- ->where('parking_management_code', $this->parkingManagementCode)
- ->firstOrFail();
-
-
- // モデル更新
- $model = HtCustomParkingName::whereCustomerCode($this->customerCode)
- ->whereParkingManagementCode($this->parkingManagementCode)
- ->firstOrNew([
- HtCustomParkingName::COL_NAME_CUSTOMER_CODE => $this->customerCode,
- HtCustomParkingName::COL_NAME_PARKING_MANAGEMENT_CODE => $this->parkingManagementCode,
- ]);
-
- $model->customer_name = $customer['name'];
- $model->parking_name = $parking['name'];
-
- $model->save();
- }
- }
|