phplaravellaravel-livewirelaravel-filamentfilamentphp

Different auth guard for filament authentication always redirecting on login page


I have a StoreUser model which is just a copy paste from User model. and on my config/auth.php I created a new guard, providers, etc.

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
    'web_store' => [
        'driver' => 'session',
        'provider' => 'store_users'
    ]
],

and on the Filament provider i set the authGuard to web_store guard.

return $panel
        ->default()
        ->id('app')
        ->path('/')
        ->login()
        ->authGuard('web_store')

but for some reason.. It seems that it keeps on redirecting to login page.. without errors.


Solution

  • After some digging i've found that it's using wrong column name of the table in auth query so to fix that we need to explicitly set the column name in model

    By default laravel will assume that column named id will be primary key for a model. But whenever you change that name of the primary column to other than id you need to explicitly set the primaryKey propery in your model. So adding the following code into App\Models\StoreUser model will fix the issue

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'store_user_id';
    

    I've sent to a PR to the repo itself