領収証発行サービス
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.8KB

  1. <?php
  2. namespace App\Mail\Common;
  3. use App\Models\Parking;
  4. use App\Models\User;
  5. use App\Models\UserDetail;
  6. use Illuminate\Support\Carbon;
  7. trait AskConfirmation
  8. {
  9. protected string $askSubject;
  10. protected string $askContents;
  11. protected string|null $parkName = null;
  12. protected string|null $userName;
  13. protected string|null $userEmail;
  14. protected int|null $seasonTicketSeqNo = null;
  15. protected Carbon|null $subscribeDatetime = null;
  16. private bool $forMember = false;
  17. abstract protected function setValues(\stdClass|array $data);
  18. protected function setAskConfirmationData(
  19. array $data,
  20. User|null $user = null,
  21. UserDetail|null $userDetail = null,
  22. Parking|null $parking = null,
  23. ) {
  24. $this->setValues($data);
  25. if ($user) {
  26. $this->userEmail = $user->email;
  27. $this->forMember = true;
  28. }
  29. if ($userDetail) {
  30. $this->userName = sprintf(
  31. "%s %s",
  32. $userDetail->first_name,
  33. $userDetail->last_name
  34. );
  35. $this->forMember = true;
  36. }
  37. if ($parking) {
  38. $this->parkName = $parking->park_name;
  39. }
  40. }
  41. public function getTemplateName(): string
  42. {
  43. return $this->forMember ? 'mails.members.ask_confirmation' : 'mails.guests.ask_confirmation';
  44. }
  45. public function getSubject(): string
  46. {
  47. return '【スマートパーキングパス】お問い合わせ内容の確認';
  48. }
  49. protected function getAskConfirmationParams(): array
  50. {
  51. return [
  52. 'askSubject' => $this->askSubject,
  53. 'askContents' => $this->askContents,
  54. 'parkName' => $this->parkName,
  55. 'userName' => $this->userName,
  56. 'userEmail' => $this->userEmail,
  57. ];
  58. }
  59. }