|
- <?php
-
- namespace App\Mail\Members\Subscription;
-
- use App\Codes\ParkingUseTypeCode;
- use App\Codes\VehicleTypeCode;
- use App\Mail\Members\Member;
- use App\Models\Parking;
- use App\Models\SeasonTicketContract;
- use App\Models\SeasonTicketContractSubscription;
- use App\Models\User;
- use Illuminate\Support\Carbon;
- use LogicException;
-
- class Approve extends Member
- {
- private string $email;
- private string $parkName;
- private Carbon|null $useStartRequestDate;
- private VehicleTypeCode $vehicleType;
- private string $contractorTypeName;
- private int $seasonTicketSeqNo;
- private int|null $confirmationCode;
- private ParkingUseTypeCode $parkingUseType;
-
- private string $customerCode;
- private string $parkingManagementCode;
-
-
- /**
- * Create a new message instance.
- *
- * @return void
- */
- public function __construct(
- User $user,
- SeasonTicketContractSubscription|null $subscription,
- Parking $parking,
- SeasonTicketContract $seasonTicketContract,
- string $contractorTypeName
- ) {
- $this->email = $user->email;
- $this->parkName = $parking->park_name;
- $this->useStartRequestDate = $subscription ? $subscription->use_start_request_date : null;
- $this->vehicleType = $seasonTicketContract->vehicle_type;
- $this->contractorTypeName = $contractorTypeName;
- $this->seasonTicketSeqNo = $seasonTicketContract->season_ticket_seq_no;
- $this->confirmationCode = $seasonTicketContract->confirmation_code;
- $this->parkingUseType = $seasonTicketContract->parking_use_type;
-
- $this->customerCode = $seasonTicketContract->customer_code;
- $this->parkingManagementCode = $seasonTicketContract->parking_management_code;
- }
-
- public function getTemplateName(): string
- {
- return 'mails.members.subscription.approve';
- }
-
- public function getSubject(): string
- {
- return '【スマートパーキングパス】定期申し込み完了';
- }
-
- public function getMemberParams(): array
- {
- return [
- 'email' => $this->email,
- 'park_name' => $this->parkName,
- 'use_start_request_date' => $this->getUseStartRequestDate(),
- 'vehicle_type' => $this->getVehicleType(),
- 'contractor_type_name' => $this->contractorTypeName,
- 'how_to_use' => $this->getHowToUse(),
- 'season_ticket_seq_no' => $this->seasonTicketSeqNo,
- 'confirmation_code' => $this->confirmationCode,
- 'ic_card_rental_request' => $this->parkingUseType === ParkingUseTypeCode::IC_RENTAL,
- 'ic_self_card_request' => $this->parkingUseType === ParkingUseTypeCode::IC_SELF,
- 'ic_qr_code_request' => $this->parkingUseType === ParkingUseTypeCode::QR,
- 'my_qr_code_url' => $this->getMyQrCodeUrl(),
- ];
- }
-
- private function getUseStartRequestDate()
- {
- if ($this->useStartRequestDate === null) return "-";
- return $this->useStartRequestDate->format("Y年m月d日");
- }
-
- private function getVehicleType()
- {
- return VehicleTypeCode::getName($this->vehicleType);
- }
-
- private function getHowToUse()
- {
- switch ($this->parkingUseType) {
- case ParkingUseTypeCode::IC_RENTAL:
- return "貸与ICカード";
- case ParkingUseTypeCode::IC_SELF:
- return "個人ICカード";
- case ParkingUseTypeCode::QR:
- return "QRコード";
- }
- throw new LogicException(sprintf("不適切な駐車場利用方法 %d", $this->parkingUseType->value));
- }
-
- private function getMyQrCodeUrl()
- {
- return $this->getAppUrl(['app', 'qrcode', 'detail', $this->customerCode, $this->parkingManagementCode]);
- }
- }
|