|
- <?php
-
- namespace App\Mail\Members\Subscription;
-
- use App\Exceptions\AppCommonException;
- use App\Mail\Members\Member;
- use Illuminate\Support\Carbon;
-
- class Entry extends Member
- {
-
- private string $email;
- private string $parkName;
- private Carbon|null $useStartRequestDate;
- private string $memo;
- /**
- * Create a new message instance.
- *
- * @return void
- */
- public function __construct()
- {
- $context = $this->context();
-
- $user = $context->getUser();
- $subscription = $context->getSeasonTicketContractSubscription();
- $parking = $context->getParking();
-
- if ($user === null) {
- throw new AppCommonException("コンテキスト不正 利用者情報");
- }
- if ($subscription === null) {
- throw new AppCommonException("コンテキスト不正 申込情報");
- }
- if ($parking === null) {
- throw new AppCommonException("コンテキスト不正 駐車場情報");
- }
-
- $this->email = $user->email;
- $this->parkName = $parking->park_name;
- $this->useStartRequestDate = $subscription->use_start_request_date;
- $this->memo = $subscription->memo ?? "";
- }
-
- public function getTemplateName(): string
- {
- return 'mails.members.subscription.entry';
- }
-
- public function getSubject(): string
- {
- return '【スマートパーキングパス】定期申し込み内容';
- }
-
- public function getMemberParams(): array
- {
- return [
- 'email' => $this->email,
- 'park_name' => $this->parkName,
- 'use_start_request_date' => $this->getUseStartRequestDate(),
- 'memo' => $this->memo
- ];
- }
-
- public function getUseStartRequestDate()
- {
- if ($this->useStartRequestDate === null) return "-";
- return $this->useStartRequestDate->format("Y年m月d日");
- }
- }
|