Create a notification
php artisan make:notification MailResetPasswordToken
edit this file which you find in a new folder App\Notifications
namespace
App\Notifications;
use
Illuminate\Bus\Queueable;
use
Illuminate\Notifications\Notification;
use
Illuminate\Contracts\Queue\ShouldQueue;
use
Illuminate\Notifications\Messages\MailMessage;
class
MailResetPasswordToken
extends
Notification
{
use
Queueable;
public
$token
;
/**
* Create a new notification instance.
*
* @return void
*/
public
function
__construct(
$token
)
{
$this
->token =
$token
;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public
function
via(
$notifiable
)
{
return
[
'mail'
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public
function
toMail(
$notifiable
)
{
return
(
new
MailMessage)
->subject(
"Reset your password"
)
->line(
"Hey, did you forget your password? Click the button to reset it."
)
->action(
'Reset Password'
, url(
'password/reset'
,
$this
->token))
->line(
'Thankyou for being a friend'
);
}
}
remembering to import the class at the top of the user model
php artisan vendor:publishIf you need to alter the layout of the message, including the text “If you’re having trouble clicking the “Reset Password” button,” then you need to runuse
App\Notifications\MailResetPasswordToken;
Override the send password reset trait with your local implementation in your User.php user model
/**
* Send a password reset email to the user
*/
public
function
sendPasswordResetNotification(
$token
)
{
$this
->notify(
new
MailResetPasswordToken(
$token
));
}
and then edit the files in
/resources/views/vendor/notifications
By: Mutasem Elayyoub