領収証発行サービス
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.9KB

  1. <?php
  2. namespace App\Mail\Members\Subscription;
  3. use App\Exceptions\AppCommonException;
  4. use App\Mail\Members\Member;
  5. use Illuminate\Support\Carbon;
  6. class Entry extends Member
  7. {
  8. private string $email;
  9. private string $parkName;
  10. private Carbon|null $useStartRequestDate;
  11. private string $memo;
  12. /**
  13. * Create a new message instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct()
  18. {
  19. $context = $this->context();
  20. $user = $context->getUser();
  21. $subscription = $context->getSeasonTicketContractSubscription();
  22. $parking = $context->getParking();
  23. if ($user === null) {
  24. throw new AppCommonException("コンテキスト不正 利用者情報");
  25. }
  26. if ($subscription === null) {
  27. throw new AppCommonException("コンテキスト不正 申込情報");
  28. }
  29. if ($parking === null) {
  30. throw new AppCommonException("コンテキスト不正 駐車場情報");
  31. }
  32. $this->email = $user->email;
  33. $this->parkName = $parking->park_name;
  34. $this->useStartRequestDate = $subscription->use_start_request_date;
  35. $this->memo = $subscription->memo ?? "";
  36. }
  37. public function getTemplateName(): string
  38. {
  39. return 'mails.members.subscription.entry';
  40. }
  41. public function getSubject(): string
  42. {
  43. return '【スマートパーキングパス】定期申し込み内容';
  44. }
  45. public function getMemberParams(): array
  46. {
  47. return [
  48. 'email' => $this->email,
  49. 'park_name' => $this->parkName,
  50. 'use_start_request_date' => $this->getUseStartRequestDate(),
  51. 'memo' => $this->memo
  52. ];
  53. }
  54. public function getUseStartRequestDate()
  55. {
  56. if ($this->useStartRequestDate === null) return "-";
  57. return $this->useStartRequestDate->format("Y年m月d日");
  58. }
  59. }