領収証発行サービス
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

93 lines
2.5KB

  1. <?php
  2. namespace App\Mail\Admins;
  3. use App\Models\Parking;
  4. use App\Models\SeasonTicketContract;
  5. use App\Models\SeasonTicketContractSubscription;
  6. use App\Models\User;
  7. use App\Models\UserDetail;
  8. use Illuminate\Support\Carbon;
  9. class Ask extends Admin
  10. {
  11. protected string $askSubject;
  12. protected string $askContents;
  13. protected string|null $parkName = null;
  14. protected string|null $userName;
  15. protected string|null $userEmail;
  16. protected int|null $seasonTicketSeqNo = null;
  17. protected Carbon|null $subscribeDatetime = null;
  18. public function __construct(
  19. array $data,
  20. User|null $user = null,
  21. UserDetail|null $userDetail = null,
  22. SeasonTicketContract|null $seasonTicketContract = null,
  23. SeasonTicketContractSubscription|null $subscription = null,
  24. Parking|null $parking = null,
  25. ) {
  26. $this->setValues($data);
  27. if ($seasonTicketContract) {
  28. $this->seasonTicketSeqNo = $seasonTicketContract->season_ticket_seq_no;
  29. }
  30. if ($subscription) {
  31. $this->subscribeDatetime = $subscription->subscribe_datetime;
  32. }
  33. if ($user) {
  34. $this->userEmail = $user->email;
  35. }
  36. if ($userDetail) {
  37. $this->userName = sprintf(
  38. "%s %s",
  39. $userDetail->first_name,
  40. $userDetail->last_name
  41. );
  42. }
  43. if ($parking) {
  44. $this->parkName = $parking->park_name;
  45. }
  46. }
  47. public function getTemplateName(): string
  48. {
  49. return 'mails.admins.ask';
  50. }
  51. public function getSubject(): string
  52. {
  53. return sprintf(
  54. '【スマートパーキングパス】【問い合わせ】【%s】%s',
  55. $this->userName,
  56. $this->askSubject
  57. );
  58. }
  59. private function memberRegistration(): string
  60. {
  61. if ($this->seasonTicketSeqNo !== null || $this->subscribeDatetime !== null) {
  62. return "あり";
  63. }
  64. return "なし";
  65. }
  66. public function getAdminParams(): array
  67. {
  68. return [
  69. 'askSubject' => $this->askSubject,
  70. 'askContents' => $this->askContents,
  71. 'parkName' => $this->parkName,
  72. 'userName' => $this->userName,
  73. 'userEmail' => $this->userEmail,
  74. 'seasonTicketSeqNo' => $this->seasonTicketSeqNo,
  75. 'subscribeDatetime' => $this->subscribeDatetime ? $this->subscribeDatetime->format('Y/m/d H:i:s') : null,
  76. 'memberRegistration' => $this->memberRegistration(),
  77. ];
  78. }
  79. }