使用Laravel 5.3更改重置密码电子邮件中的视图

I'm using Laravel 5.3 and I'm working now on the reset password option on my CRM.

my CRM is multi-language therefore I need to change the email template / the view that sent to the customer based on his language, actually, I just need to change from RTL to LTR - this value is set on a cookie that called "user_direction".

I'm using the Laravel default bootstrap auth that includes ResetPassword class.

this is what is have now:

<?php

namespace Illuminate\Auth\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;

class ResetPassword extends Notification
{
    public $token;

    public function __construct($token)
    {
        $this->token = $token;
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        $url        = url('password/reset',$this->token);
        $subject    = trans('global.reset_password_email_subject'); 
        $greeting   = trans('global.reset_password_email_greeting'); 
        $line_01    = trans('global.reset_password_email_line_01'); 
        $action     = trans('global.reset_password_email_action'); 
        $line_02    = trans('global.reset_password_email_line_02'); 

        return (new MailMessage)
            ->subject($subject)
            ->greeting($greeting)
            ->line($line_01)
            ->action($action, $url)
            ->line($line_02);
    }
}

and this is the idea of what i want to have but i dont know how to write it right:

    public function toMail($notifiable)
    {
        $url        = url('password/reset',$this->token);
        $subject    = trans('global.reset_password_email_subject'); 
        $greeting   = trans('global.reset_password_email_greeting'); 
        $line_01    = trans('global.reset_password_email_line_01'); 
        $action     = trans('global.reset_password_email_action'); 
        $line_02    = trans('global.reset_password_email_line_02'); 

        $view = "notifications::email";
        if($request->cookie('user_direction') == "rtl"):
            $view = "notifications::email-rtl";
        endif;

        return (new MailMessage)
            ->view($view)
            ->subject($subject)
            ->greeting($greeting)
            ->line($line_01)
            ->action($action, $url)
            ->line($line_02);
    }

thank you for your help!

You can change the reset passwords view by overriding the function in ResetPasswords Trait.

Simply add the following function to the ResetPasswordController and modify your view.

/**
 * Display the password reset view for the given token.
 *
 * If no token is present, display the link request form.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  string|null  $token
 * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
 */
public function showResetForm(Request $request, $token = null)
{
    return view('auth.passwords.reset')->with(
        ['token' => $token, 'email' => $request->email]
    );
}

after watching some tutorials on youtube it worked for me, i wrote it this way:

first I add "use Cookie;"

public function toMail($notifiable)
{
    $user_language_direction = Cookie::get('user_direction');

    $url        = url('password/reset',$this->token);
    $subject    = trans('global.reset_password_email_subject'); 
    $greeting   = trans('global.reset_password_email_greeting'); 
    $line_01    = trans('global.reset_password_email_line_01'); 
    $action     = trans('global.reset_password_email_action'); 
    $line_02    = trans('global.reset_password_email_line_02'); 

    $view       = "notifications::email";
    if($user_language_direction == "rtl")
        $view   = "notifications::email-rtl";

    return (new MailMessage)
        ->view($view,array())
        ->subject($subject)
        ->greeting($greeting)
        ->line($line_01)
        ->action($action, $url)
        ->line($line_02);
}