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

66 lines
1.3KB

  1. <?php
  2. namespace App\Mail\Guests;
  3. use App\Models\EmailVerify as ModelsEmailVerify;
  4. use Exception;
  5. use Illuminate\Support\Carbon;
  6. class EmailVerify extends Guest
  7. {
  8. protected string $token;
  9. protected Carbon $expiresAt;
  10. protected $casts = [
  11. 'expiresAt' => 'datetime',
  12. ];
  13. /**
  14. * Create a new message instance.
  15. *
  16. * @return void
  17. */
  18. public function __construct(ModelsEmailVerify $model)
  19. {
  20. $this->setValues($model->toArray());
  21. }
  22. public function getTemplateName(): string
  23. {
  24. return 'mails.guests.email_verify';
  25. }
  26. public function getSubject(): string
  27. {
  28. return '【スマートパーキングパス】会員登録のご案内';
  29. }
  30. public function getGuestParams(): array
  31. {
  32. return [
  33. 'url' => $this->getUrl(),
  34. 'expiresAt' => $this->getExpiresAt(),
  35. ];
  36. }
  37. private function getUrl()
  38. {
  39. return implode(
  40. "/",
  41. [
  42. config("app.url"),
  43. 'register/user',
  44. $this->token
  45. ]
  46. );
  47. }
  48. private function getExpiresAt()
  49. {
  50. $date = $this->expiresAt;
  51. if ($date !== null) {
  52. return $date->format('Y/m/d H:i');
  53. }
  54. throw new Exception("有効期限日付不正");
  55. }
  56. }