Overview
Laravel provides by default a forgot password feature for User
model, you can find it in authorizable
alias that extends to User
model:
class User extends Model implements
AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract
{
use Authenticatable, Authorizable, CanResetPassword, MustVerifyEmail;
}
User
model has a method that send the notification to reset password:
sendPasswordResetNotification($token)
We can override it to handle or custom messages.
Customizing Reset Password notification
First, we are going to create or own notification that would extend from the default ResetPassword
notification from Laravel:
In terminal create a new notification:
php artisan make:notification ResetPassword
Then we are going to override sendPasswordResetNotification
method in User
model:
use App\Notifications\ResetPassword;
class User
{
// ...
public function sendPasswordResetNotification($token)
{
$this->notify(new ResetPassword($token));
}
}
Just make sure that you import our custom notification.
Customize notification
In this example for the sake of simplicity I am going to extend from the default resetPassword
from Laravel
Eg: replace a subject message:
protected function buildMailMessage($url)
{
return (new MailMessage)->subject('Here a custom subject');
}
Top comments (1)
Hi,
This is Sourov Pal. I am a freelance web developer and Software Developer. I can do one of project for free. If you like my work you will pay me otherwise you don't need to pay. No upfront needed, no contract needed. If you want to outsource your work to me you may knock me.
My what's app no is: +8801919852044
Github Profile: github.com/sourovpal
Thanks
Some comments have been hidden by the post's author - find out more