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

77 lines
1.6KB

  1. <?php
  2. namespace App\Mail\Members;
  3. use App\Models\ResetPassword;
  4. use App\Models\User;
  5. use Illuminate\Support\Carbon;
  6. class UserRegisterComplete extends Member
  7. {
  8. private string $email;
  9. private bool $includePasswordReset = false;
  10. private Carbon|null $expiresAt = null;
  11. private string $token = "";
  12. /**
  13. * Create a new message instance.
  14. *
  15. * @return void
  16. */
  17. public function __construct(User $model, ResetPassword|null $password = null)
  18. {
  19. $this->email = $model->email;
  20. if ($password !== null) {
  21. $this->includePasswordReset = true;
  22. $this->expiresAt = $password->expires_at;
  23. $this->token = $password->token;
  24. }
  25. }
  26. public function getTemplateName(): string
  27. {
  28. return 'mails.members.user_register_complete';
  29. }
  30. public function getSubject(): string
  31. {
  32. return '【スマートパーキングパス】会員登録完了';
  33. }
  34. public function getMemberParams(): array
  35. {
  36. return [
  37. 'email' => $this->email,
  38. 'includePasswordReset' => $this->includePasswordReset,
  39. 'url' => $this->getUrl(),
  40. 'expiresAt' => $this->getExpiresAt(),
  41. ];
  42. }
  43. private function getUrl()
  44. {
  45. return implode(
  46. "/",
  47. [
  48. config("app.url"),
  49. 'password-reset',
  50. $this->token
  51. ]
  52. );
  53. }
  54. private function getExpiresAt()
  55. {
  56. if ($this->expiresAt === null) {
  57. return "";
  58. } else {
  59. return $this->expiresAt->format('Y/m/d H:i');
  60. }
  61. }
  62. }