|
- <?php
-
- namespace App\Mail\Common;
-
- use App\Models\Parking;
- use App\Models\User;
- use App\Models\UserDetail;
- use Illuminate\Support\Carbon;
-
- trait AskConfirmation
- {
-
- protected string $askSubject;
- protected string $askContents;
- protected string|null $parkName = null;
- protected string|null $userName;
- protected string|null $userEmail;
- protected int|null $seasonTicketSeqNo = null;
- protected Carbon|null $subscribeDatetime = null;
-
- private bool $forMember = false;
-
- abstract protected function setValues(\stdClass|array $data);
-
- protected function setAskConfirmationData(
- array $data,
- User|null $user = null,
- UserDetail|null $userDetail = null,
- Parking|null $parking = null,
- ) {
- $this->setValues($data);
- if ($user) {
- $this->userEmail = $user->email;
- $this->forMember = true;
- }
- if ($userDetail) {
- $this->userName = sprintf(
- "%s %s",
- $userDetail->first_name,
- $userDetail->last_name
- );
- $this->forMember = true;
- }
- if ($parking) {
- $this->parkName = $parking->park_name;
- }
- }
-
- public function getTemplateName(): string
- {
- return $this->forMember ? 'mails.members.ask_confirmation' : 'mails.guests.ask_confirmation';
- }
-
- public function getSubject(): string
- {
- return '【スマートパーキングパス】お問い合わせ内容の確認';
- }
-
- protected function getAskConfirmationParams(): array
- {
- return [
- 'askSubject' => $this->askSubject,
- 'askContents' => $this->askContents,
-
- 'parkName' => $this->parkName,
- 'userName' => $this->userName,
- 'userEmail' => $this->userEmail,
- ];
- }
- }
|