diff --git a/app/Models/Admin.php b/app/Models/Admin.php index 52515a4..78cd871 100644 --- a/app/Models/Admin.php +++ b/app/Models/Admin.php @@ -44,6 +44,8 @@ class Admin extends Authenticatable // We are overriding the sendPasswordRestNotification email public function sendPasswordResetNotification($token) { - $this->notify(new AdminResetPasswordNotification($token)); + // `$this` has instance of the model so we get the email attribute value and pass to the + // notification so it includes also the email in the Mail that we will send. + $this->notify(new AdminResetPasswordNotification($token, $this->email)); } } diff --git a/app/Notifications/AdminResetPasswordNotification.php b/app/Notifications/AdminResetPasswordNotification.php index 180e01c..be7c0a5 100644 --- a/app/Notifications/AdminResetPasswordNotification.php +++ b/app/Notifications/AdminResetPasswordNotification.php @@ -12,15 +12,18 @@ class AdminResetPasswordNotification extends Notification use Queueable; public $token; + public $email; /** * Create a new notification instance. * - * @return void + * @param $token + * @param null $email */ - public function __construct($token) + public function __construct($token, $email = null) { $this->token = $token; + $this->email = $email; } /** @@ -45,9 +48,11 @@ public function toMail($notifiable) // Currently, In our action method: // The "admin.password.reset" route is the unique route that receiver will receive through email. // This receive email will contains user email & token. + // route('admin.password.reset', $this->token)) translates into http://localhost/admin/password/reset/033860c11059dcc4c + // route('admin.password.reset', [$this->token, 'email' => $this->email]) translates into http://localhost/admin/password/reset/033860c11059dcc4c?email=h@h.com return (new MailMessage) ->line('You request to reset your password.') - ->action('Reset Password Action', route('admin.password.reset', $this->token)) + ->action('Reset Password Action', route('admin.password.reset', [$this->token, 'email' => $this->email])) ->line('Thank you for using our application!'); }