Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Arturexe's avatar

How to customize Password Reset Link in Laravel 9?

I'm trying to change the URL inside the Password Reset Link. The Laravel 9 docs say to add this to the User.php model:

use App\Notifications\ResetPasswordNotification;
 
/**
 * Send a password reset notification to the user.
 *
 * @param  string  $token
 * @return void
 */
public function sendPasswordResetNotification($token)
{
    $url = 'https://example.com/reset-password?token='.$token;
 
    $this->notify(new ResetPasswordNotification($url));
}

ResetPasswordNotification does not seem to be in my file system (Laravel 9.43.0). Instead I found ResetPassword class from the same location which seems to replace ResetPasswordNotification. I've added this to User.php model:

use Illuminate\Auth\Notifications\ResetPassword;

public function sendPasswordResetNotification($token)
{

    $url = 'https://example.com/reset-password?token='.$token;

    $this->notify(new ResetPassword($url));
}

but the link that is sent to my email is this:

http://localhost:3000/password-reset/https://example.com/reset-password?token=4d9d948903e9264653b224e423c6b27e9fce2c901876c3372d3561523f09fcb9?email=ArturMuellerRomanov@gmail.com

As you can see the $url variable string gets inserted in between the real URL and $token. How do I REPLACE the URL instead?

0 likes
2 replies
EchelonStudio's avatar

what starter kit are you using or you are doing it manually ?

Arturexe's avatar
Arturexe
OP
Best Answer
Level 1

Thanks to a guy (who deleted his answer) I've read this part more thoroughly, which tells to add a method to the AuthServiceProvider.php. I haven't realized that this method already existed in my case because I'm using the laravel/breeze -api package:

public function boot()
    {
        $this->registerPolicies();

        ResetPassword::createUrlUsing(function ($notifiable, $token) {
            return config('app.frontend_url')."/password-reset/.$token?email={$notifiable->getEmailForPasswordReset()}";
        });

        //
    }

There I can easily customize the URL.

2 likes

Please or to participate in this conversation.