System message ResetPassword , according to the standard located in the directory

 vendor/laravel/framework/src/illuminate/auth/notifications/ 

 <?php namespace Illuminate\Auth\Notifications; use Illuminate\Notifications\Notification; use Illuminate\Notifications\Messages\MailMessage; class ResetPassword extends Notification { /** * The password reset token. * * @var string */ public $token; /** * Create a notification instance. * * @param string $token * @return void */ public function __construct($token) { $this->token = $token; } /** * Get the notification's channels. * * @param mixed $notifiable * @return array|string */ public function via($notifiable) { return ['mail']; } /** * Build the mail representation of the notification. * * @param mixed $notifiable * @return \Illuminate\Notifications\Messages\MailMessage */ public function toMail($notifiable) { return (new MailMessage) ->line('You are receiving this email because we received a password reset request for your account.') ->action('Reset Password', url(config('app.url').route('password.reset', $this->token, false))) ->line('If you did not request a password reset, no further action is required.'); } } 

I try to create a localized copy of it, copy it into all possible folders, such as app / notifications anyway, the application does not see it and uses the standard class. What am I doing wrong?

    1 answer 1

    Found an answer on the English stack and realized my mistake

    Summary of how to make your version of the standard system message Laravel:

    1) We generate our own template: php artisan make:notification ResetPassword , it will appear in the app\Notifications directory;

    2) In the received file in return (new MailMessage) add the subject of the letter ->subject() , so that the sending looks like this:

      public function toMail($notifiable) { return (new MailMessage) ->subject('Тема') ->line('Тело письма часть 1') ->action('Название кнопки', url('password/reset', $this->token)) ->line('Тело письма часть 2'); } 

    3) In app\User.php override the standard sendPasswordResetNotification() method

     <?php namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; ... //встраиваем ваш обработчик use App\Notifications\ResetPassword as ResetPasswordNotification; class User extends Authenticatable { use Notifiable; ... public function sendPasswordResetNotification($token) { // Добавляем свой класс. $this->notify(new ResetPasswordNotification($token)); } } 

    The field of these manipulations will receive your notification version in the mail.