help

I have three tablets in the data base User, admin, and company employee I want to build a filament exclusively for the company's employees The log account means that the only person entering the dashboard is a company employee I tried to use Filament, but the account was registered in the user table
15 Replies
Dennis Koch
Dennis Koch4w ago
I tried to use Filament, but the account was registered in the user table
Yes. That's just the default user:generate command. You can use any auth though. You can overwrite the auth guard that Filament uses via ->authGuard() on the PanelProvider. Just use the guard that only allows company employees.
Aya Alghadban
Aya Alghadban4w ago
class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('admin') ->login() ->colors([ 'primary' => Color::Amber, ]) ->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages') ->pages([ Pages\Dashboard::class, ]) ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets') ->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class, ]) ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class, AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, ]) ->authMiddleware([ Authenticate::class, ]); } } in this code where can i edit to accept only company_employee for login
Dennis Koch
Dennis Koch4w ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
Dennis Koch
Dennis Koch4w ago
Usually you would just define an auth guard via config/auth.php
Aya Alghadban
Aya Alghadban4w ago
i create already guard how can i put it in filament to access only company_employee
Dennis Koch
Dennis Koch4w ago
Example:
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],

'providers' => [
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
'guards' => [
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
],

'providers' => [
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
->authGuard('your_guard') on the Panel
Aya Alghadban
Aya Alghadban4w ago
class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->default() ->id('admin') ->path('company') ->login() ->colors([ 'primary' => Color::Amber, ]) ->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources') ->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages') ->pages([ Pages\Dashboard::class, ]) ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets') ->widgets([ Widgets\AccountWidget::class, Widgets\FilamentInfoWidget::class, ]) ->middleware([ EncryptCookies::class, AddQueuedCookiesToResponse::class, StartSession::class, AuthenticateSession::class, ShareErrorsFromSession::class, VerifyCsrfToken::class, SubstituteBindings::class, DisableBladeIconComponents::class, DispatchServingFilamentEvent::class, ]) ->authMiddleware([ Authenticate::class, ])->authGuard('employees'); } } i put this code the error is BadMethodCallException PHP 8.1.10 10.48.12 Method Illuminate\Auth\RequestGuard::attempt does not exist. Bad Method Call Did you mean Illuminate\Auth\RequestGuard::validate() ?
No description
No description
Dennis Koch
Dennis Koch4w ago
Please use code formatting as explained in #✅┊rules Is employees an actual guard? Can you show config/auth.php
Aya Alghadban
Aya Alghadban4w ago
this all guards for my project
No description
Aya Alghadban
Aya Alghadban4w ago
this all providers
No description
Aya Alghadban
Aya Alghadban4w ago
i saw new error in employee table i have this columns and my code for login is in third image how can i connect my login function with login page in filament
No description
No description
No description
Aya Alghadban
Aya Alghadban4w ago
and the page not retuns to login page
No description
toeknee
toeknee4w ago
The column is not found.
Aya Alghadban
Aya Alghadban4w ago
i want customize my table in the filament
Dennis Koch
Dennis Koch4w ago
You can extend the Login page and set your new page via ->login() inside the panel provider. Not sure whether sanctum works. I guess it should be session for filament.