From a85ec6efb3aeb36078d4be132d9cbe87d1564adf Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 15 Jul 2025 14:12:42 +0100 Subject: [PATCH] Set token in welcome email constructor Signed-off-by: snipe --- app/Notifications/WelcomeNotification.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/Notifications/WelcomeNotification.php b/app/Notifications/WelcomeNotification.php index 1e27ca7364..a370f1188e 100644 --- a/app/Notifications/WelcomeNotification.php +++ b/app/Notifications/WelcomeNotification.php @@ -5,26 +5,24 @@ namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use Illuminate\Support\Facades\Password; +use App\Models\User; class WelcomeNotification extends Notification { use Queueable; - private $_data = []; + public string $passwordResetUrl; /** * Create a new notification instance. * * @return void */ - public function __construct(array $content) + public function __construct(public User $user) { - $this->_data['email'] = htmlspecialchars_decode($content['email']); - $this->_data['first_name'] = htmlspecialchars_decode($content['first_name']); - $this->_data['last_name'] = htmlspecialchars_decode($content['last_name']); - $this->_data['username'] = htmlspecialchars_decode($content['username']); - $this->_data['password'] = htmlspecialchars_decode($content['password']); - $this->_data['url'] = config('app.url'); + $this->user->token = Password::getRepository()->create($user); + } /** @@ -44,8 +42,11 @@ class WelcomeNotification extends Notification */ public function toMail() { + + \Log::error(print_r($this->user->toArray(), true)); + return (new MailMessage()) - ->subject(trans('mail.welcome', ['name' => $this->_data['first_name'].' '.$this->_data['last_name']])) - ->markdown('notifications.Welcome', $this->_data); + ->subject(trans('mail.welcome', ['name' => $this->user->first_name.' '.$this->user->last_name])) + ->markdown('notifications.Welcome', $this->user->toArray()); } }