Multiple login models
Hello, how can I use multiple models to diferent logins?
Like
user
model and consumer
model?
I tried to build diferent panels and set a Login class in a customer panel, like that:
So, in AppLogin
class, I have duplicated all default Login class ( Filament\Pages\Auth\Login.php
)
Well.. I think in the method I need to pass something to indicate I´d like to get Consumer models instead User model right?
But I really don´t know what I need to do here..
Someone can help me? ThanksSolution:Jump to solution
Maybe you need to set AuthGuard? https://filamentphp.com/docs/3.x/panels/users#setting-the-authentication-guard
4 Replies
Solution
Maybe you need to set AuthGuard? https://filamentphp.com/docs/3.x/panels/users#setting-the-authentication-guard
Auth guards are the way to go.
You will need to define a new AuthGuard
guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'hash' => false,
],
'consumer' => [ 'driver' => 'session', 'provider' => 'consumers', ], ], And then associate the provider with your model 'providers' => [ 'consumers' => [ 'driver' => 'eloquent', 'model' => App\Consumers::class, ], Then use the new AuthGuard in the filament panel
'consumer' => [ 'driver' => 'session', 'provider' => 'consumers', ], ], And then associate the provider with your model 'providers' => [ 'consumers' => [ 'driver' => 'eloquent', 'model' => App\Consumers::class, ], Then use the new AuthGuard in the filament panel
Thank you guys, awesome help 💪
Appreciate it 🚀