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
17 Replies
Dennis Koch
Dennis Koch6mo 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 AlghadbanOP6mo 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 Koch6mo 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 Koch6mo ago
Usually you would just define an auth guard via config/auth.php
Aya Alghadban
Aya AlghadbanOP6mo ago
i create already guard how can i put it in filament to access only company_employee
Dennis Koch
Dennis Koch6mo 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 AlghadbanOP6mo 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 Koch6mo ago
Please use code formatting as explained in #✅┊rules Is employees an actual guard? Can you show config/auth.php
Aya Alghadban
Aya AlghadbanOP6mo ago
this all guards for my project
No description
Aya Alghadban
Aya AlghadbanOP6mo ago
this all providers
No description
Aya Alghadban
Aya AlghadbanOP6mo 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 AlghadbanOP6mo ago
and the page not retuns to login page
No description
toeknee
toeknee6mo ago
The column is not found.
Aya Alghadban
Aya AlghadbanOP6mo ago
i want customize my table in the filament
Dennis Koch
Dennis Koch6mo 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.
Aya Alghadban
Aya AlghadbanOP5mo ago
hello i have this resource in message.txt in createproduct file i have this code <?php namespace App\Filament\Resources\ProductResource\Pages; use App\Filament\Resources\ProductResource; use App\Models\Product; use App\Models\ProductUnit; use Filament\Actions; use Filament\Resources\Pages\CreateRecord; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; class CreateProduct extends CreateRecord { protected static string $resource = ProductResource::class; protected function handleRecordCreation(array $data): Product { return DB::transaction(function () use ($data) { $product = Product::create($data); if (isset($data['units'])) { foreach ($data['units'] as $unitData) { ProductUnit::create([ 'product_id' => $product->id, 'unit_id' => $unitData['unit_id'], 'price' => $product['price'], ]); } } return $product; }); } } when i create units and prices for new product i saw this error SQLSTATE[HY000]: General error: 1364 Field 'price' doesn't have a default value how can i fix it to create many unites and prices for product the relationship between products and units is manyto many
Dennis Koch
Dennis Koch5mo ago
@Aya Alghadban Is this related to the original issue? Please use one thread per question and use code formatting as mentioned in #✅┊rules
Want results from more Discord servers?
Add your server