Changing the Laravel 5 password reset email text and Template

Create a notification

php artisan make:notification MailResetPasswordToken

edit this file which you find in a new folder App\Notifications

 

namespaceApp\Notifications;

 

useIlluminate\Bus\Queueable;

useIlluminate\Notifications\Notification;

useIlluminate\Contracts\Queue\ShouldQueue;

useIlluminate\Notifications\Messages\MailMessage;

 

classMailResetPasswordToken extendsNotification

{

    useQueueable;

 

    public$token;

 

    /**

     * Create a new notification instance.

     *

     * @return void

     */

    publicfunction__construct($token)

    {

        $this->token = $token;

    }

 

    /**

     * Get the notification's delivery channels.

     *

     * @param  mixed  $notifiable

     * @return array

     */

    publicfunctionvia($notifiable)

    {

        return['mail'];

    }

 

    /**

     * Get the mail representation of the notification.

     *

     * @param  mixed  $notifiable

     * @return \Illuminate\Notifications\Messages\MailMessage

     */

    publicfunctiontoMail($notifiable)

    {

        return(newMailMessage)

                    ->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 run

useApp\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

 */

publicfunctionsendPasswordResetNotification($token)

{

    $this->notify(newMailResetPasswordToken($token));

}

and then edit the files in

/resources/views/vendor/notifications

By: Mutasem Elayyoub