Finally figured all out, if anyone needs it:
Issue 1:
To adjust the link of the button inside the password reset email body we need to:
make a new password reset notification class
Edit the ResetPassword notification class and its constructor to accept the token
Overide the method on the user model
Let’s start by making a new notification class using the following artisan command:
php artisan make:notification ResetPassword
Then we modify the file in app/Notifications/ResetPassword.php in the following way:
use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification;
Above we import the new ResetPassword notification class then change class in the following way, adding the extends ResetPasswordNotification and token inside the construct like so:
class ResetPassword extends ResetPasswordNotification
{
use Queueable;
public $token;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($token)
{
$this->token = $token;
}
Continuing in the same file, we need to edit the toMail method like so:
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
$locale = app()->getLocale();
return (new MailMessage)
->subject('Reset your password - ' . config('app.name'))
->line('Hey this email was sent to you because you requested a password change for your order.')
->action('Reset Password', url($locale . '/password/reset', $this->token))
->line(' if you did not request a password change, please ignore this email.');
}
Now we need to override the method sendPasswordResetNotification inside the User class, in the file app/Http/User.php
First we Import the new ResetPassword class at the top
use App\Notifications\ResetPassword;
Then we Override the method
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
}
Issue 2:
On the reset.blade.php view, the request returns the locale “en” instead of the password reset token value.
If I dd($request->all()) on the ResetPasswordController@reset method this is what I was gettting:
array:5 [▼
“_token” => “YrwPp06e6dV3iVlyQ59y1lvcNvOwCoQr0bIyAwgX”
“token” => “en”
“email” => “[email protected]”
“password” => “password”
“password_confirmation” => “password”
]
This is solved by Changing the showResetForm method from:
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset')->with(
['token' => $token, 'email' => $request->email]
);
}
To:
public function showResetForm(Request $request, $token = null)
{
$token = $request->token;
return view('auth.passwords.reset')->with(
['token' => $token, 'email' => $request->email]
);
}
I wrote a complete multi-language guide for future reference, it's available on my site: https://fabiopacifici.com/laravel-5-7-multi-language-complete-guide/