|
- <?php
-
- namespace App\Mail\Admins;
-
- use App\Models\Parking;
- use App\Models\SeasonTicketContract;
- use App\Models\SeasonTicketContractSubscription;
- use App\Models\User;
- use App\Models\UserDetail;
- use Illuminate\Support\Carbon;
-
- class Ask extends Admin
- {
-
- 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;
-
-
- public function __construct(
- array $data,
- User|null $user = null,
- UserDetail|null $userDetail = null,
- SeasonTicketContract|null $seasonTicketContract = null,
- SeasonTicketContractSubscription|null $subscription = null,
- Parking|null $parking = null,
- ) {
- $this->setValues($data);
- if ($seasonTicketContract) {
- $this->seasonTicketSeqNo = $seasonTicketContract->season_ticket_seq_no;
- }
- if ($subscription) {
- $this->subscribeDatetime = $subscription->subscribe_datetime;
- }
- if ($user) {
- $this->userEmail = $user->email;
- }
- if ($userDetail) {
- $this->userName = sprintf(
- "%s %s",
- $userDetail->first_name,
- $userDetail->last_name
- );
- }
- if ($parking) {
- $this->parkName = $parking->park_name;
- }
- }
-
- public function getTemplateName(): string
- {
- return 'mails.admins.ask';
- }
-
- public function getSubject(): string
- {
- return sprintf(
- '【スマートパーキングパス】【問い合わせ】【%s】%s',
- $this->userName,
- $this->askSubject
- );
- }
-
- private function memberRegistration(): string
- {
- if ($this->seasonTicketSeqNo !== null || $this->subscribeDatetime !== null) {
- return "あり";
- }
- return "なし";
- }
-
- public function getAdminParams(): array
- {
- return [
- 'askSubject' => $this->askSubject,
- 'askContents' => $this->askContents,
-
- 'parkName' => $this->parkName,
- 'userName' => $this->userName,
- 'userEmail' => $this->userEmail,
-
- 'seasonTicketSeqNo' => $this->seasonTicketSeqNo,
- 'subscribeDatetime' => $this->subscribeDatetime ? $this->subscribeDatetime->format('Y/m/d H:i:s') : null,
-
- 'memberRegistration' => $this->memberRegistration(),
- ];
- }
- }
|