DEV Community

Son Kon
Son Kon

Posted on

🔐 Using a Custom Model for Laravel Breeze (e.g. Guest Instead of User)

Laravel’s default authentication setup assumes you’re using a User model. But what if your app requires a different model—like Guest?

In this quick guide, I’ll show you how to make Laravel Breeze work with a custom model, and how to fix the common “Forgot Password” issue when using anything other than the default User model.

✅ What I’m Using

**Laravel Breeze** for lightweight authentication scaffolding

A custom Guest model instead of the default User model
Enter fullscreen mode Exit fullscreen mode

💡 The Problem

Everything works great—login, registration, etc.—until a guest tries to reset their password.

Laravel’s built-in "Forgot Password" functionality fails. Why?

Because by default, Laravel’s password reset is configured to use the users table and the User model. If you're using guests, this won’t work out of the box.

🛠️ The Fix

To get password resets working with your Guest model, head over to config/auth.php and update the passwords section like this:

'passwords' => [
    'users' => [
        'provider' => 'users',
        'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
        'expire' => 60,
        'throttle' => 60,
    ],
    'guests' => [
        'provider' => 'guests',
        'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
        'expire' => 60,
        'throttle' => 60,
    ],
],
Enter fullscreen mode Exit fullscreen mode

Also, ensure your auth providers are correctly set up:

'providers' => [
    'guests' => [
        'driver' => 'eloquent',
        'model' => App\Models\Guest::class,
    ],
],
Enter fullscreen mode Exit fullscreen mode

Then, Apply this changes in your Auth/PasswordResetLinkController.php

public function store(Request $request): RedirectResponse
{
    $request->validate([
        'email' => ['required', 'email'],
    ]);

    $status = Password::broker('guests')->sendResetLink( //add broker function in Password
        $request->only('email')
    );

    return $status == Password::RESET_LINK_SENT
        ? back()->with('status', __($status))
        : back()->withInput($request->only('email'))
        ->withErrors(['email' => __($status)]);
}
Enter fullscreen mode Exit fullscreen mode

And in Auth\NewPasswordController

    public function store(Request $request): RedirectResponse
    {
        $request->validate([
            'token' => ['required'],
            'email' => ['required', 'email'],
            'password' => ['required', 'confirmed', Rules\Password::defaults()],
        ]);


        $status = Password::broker('guests')->reset( //add broker function to point to your guest passwords provider
            $request->only('email', 'password', 'password_confirmation', 'token'),
            function (Guest $user) use ($request) { // dont forget about what model you are using here
                $user->forceFill([
                    'password' => Hash::make($request->password),
                    'remember_token' => Str::random(60),
                ])->save();

                event(new PasswordReset($user));
            }
        );
}
Enter fullscreen mode Exit fullscreen mode

Now Laravel will know to send the reset password link to a guest, and look them up using the guests table and Guest model.

🎉 That’s It!

With these small tweaks, your Laravel app is now fully compatible with custom-authenticated models—complete with password reset support.

Top comments (0)