<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Son Kon</title>
    <description>The latest articles on DEV Community by Son Kon (@son_kon_4a3af2ad413ea1393).</description>
    <link>https://dev.to/son_kon_4a3af2ad413ea1393</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3184466%2F307c75af-f5b3-42d3-88c7-f7705be2f724.jpg</url>
      <title>DEV Community: Son Kon</title>
      <link>https://dev.to/son_kon_4a3af2ad413ea1393</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/son_kon_4a3af2ad413ea1393"/>
    <language>en</language>
    <item>
      <title>🔐 Using a Custom Model for Laravel Breeze (e.g. Guest Instead of User)</title>
      <dc:creator>Son Kon</dc:creator>
      <pubDate>Tue, 20 May 2025 11:27:00 +0000</pubDate>
      <link>https://dev.to/son_kon_4a3af2ad413ea1393/using-a-custom-model-for-laravel-authentication-eg-guest-instead-of-user-35jl</link>
      <guid>https://dev.to/son_kon_4a3af2ad413ea1393/using-a-custom-model-for-laravel-authentication-eg-guest-instead-of-user-35jl</guid>
      <description>&lt;p&gt;Laravel’s default authentication setup assumes you’re using a User model. But what if your app requires a different model—like Guest?&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;✅ What I’m Using&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;**Laravel Breeze** for lightweight authentication scaffolding

A custom Guest model instead of the default User model
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;💡 The Problem&lt;/p&gt;

&lt;p&gt;Everything works great—login, registration, etc.—until a guest tries to reset their password.&lt;/p&gt;

&lt;p&gt;Laravel’s built-in "Forgot Password" functionality fails. Why?&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;🛠️ The Fix&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'passwords' =&amp;gt; [
    'users' =&amp;gt; [
        'provider' =&amp;gt; 'users',
        'table' =&amp;gt; env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
        'expire' =&amp;gt; 60,
        'throttle' =&amp;gt; 60,
    ],
    'guests' =&amp;gt; [
        'provider' =&amp;gt; 'guests',
        'table' =&amp;gt; env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
        'expire' =&amp;gt; 60,
        'throttle' =&amp;gt; 60,
    ],
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Also, ensure your auth providers are correctly set up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;'providers' =&amp;gt; [
    'guests' =&amp;gt; [
        'driver' =&amp;gt; 'eloquent',
        'model' =&amp;gt; App\Models\Guest::class,
    ],
],
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, Apply this changes in your Auth/PasswordResetLinkController.php&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public function store(Request $request): RedirectResponse
{
    $request-&amp;gt;validate([
        'email' =&amp;gt; ['required', 'email'],
    ]);

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

    return $status == Password::RESET_LINK_SENT
        ? back()-&amp;gt;with('status', __($status))
        : back()-&amp;gt;withInput($request-&amp;gt;only('email'))
        -&amp;gt;withErrors(['email' =&amp;gt; __($status)]);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And in Auth\NewPasswordController&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public function store(Request $request): RedirectResponse
    {
        $request-&amp;gt;validate([
            'token' =&amp;gt; ['required'],
            'email' =&amp;gt; ['required', 'email'],
            'password' =&amp;gt; ['required', 'confirmed', Rules\Password::defaults()],
        ]);


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

                event(new PasswordReset($user));
            }
        );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now Laravel will know to send the reset password link to a guest, and look them up using the guests table and Guest model.&lt;/p&gt;

&lt;p&gt;🎉 That’s It!&lt;/p&gt;

&lt;p&gt;With these small tweaks, your Laravel app is now fully compatible with custom-authenticated models—complete with password reset support.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
