thisisthejay
thisisthejay
FFilament
Created by thisisthejay on 6/10/2024 in #❓┊help
I am getting a 404 on my create page in a second panel
I had it working previously. I have a Report creation page in a Teacher panel. The ReportResource mirrors my admin ReportResoucre and the CreateReport page was generated using the artisan command at the beginning of the project
php artisan make:filament-resource Customer --generate
php artisan make:filament-resource Customer --generate
I even tried re-generating them but I still get a 404 only on the Create route I checked that it is registered in my ReportResource and it looks like this:
public static function getPages(): array
{
return [
'index' => Pages\ListReports::route('/'),
'view' => Pages\ViewReport::route('/{record}'),
'create' => Pages\CreateReport::route('/create'),
'edit' => Pages\EditReport::route('/{record}/edit'),
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListReports::route('/'),
'view' => Pages\ViewReport::route('/{record}'),
'create' => Pages\CreateReport::route('/create'),
'edit' => Pages\EditReport::route('/{record}/edit'),
];
}
All other pages are working and the CreateReport.php file exists.
3 replies
FFilament
Created by thisisthejay on 6/9/2024 in #❓┊help
Best Practice for Multi-Panel Auth and Redirects
What is the best practice for: - permissioning access to separate panels - redirecting to a specific panel on login based on roles I am using Filament Shield (with Spatie Roles and Permissions) I have the following panels: - Admin (default) - Teachers - Students - HR Admin should be accessibe by roles: 'Admin' and 'super_admin', Teachers by 'Teachers', Students by 'Students' and HR by 'Human Resources' I adapted the User Model as follows which worked Locally but in production I couldn't access any Panels even as super_admin:
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Admin']);
} else if ($panel->getId() === 'hr') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Human Resources']);
} else if ($panel->getId() === 'teachers') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Teacher']);
} else if ($panel->getId() === 'students') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Student']);
}
return false;
}
public function canAccessPanel(Panel $panel): bool
{
if ($panel->getId() === 'admin') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Admin']);
} else if ($panel->getId() === 'hr') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Human Resources']);
} else if ($panel->getId() === 'teachers') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Teacher']);
} else if ($panel->getId() === 'students') {
return $this->email && $this->hasVerifiedEmail() && $this->hasRole(['Student']);
}
return false;
}
1 replies
FFilament
Created by thisisthejay on 10/9/2023 in #❓┊help
FIlament Shield Error
I upgraded to v3 and have Filament Shield for the roles. I am getting the following error message:
Non-static method BezhanSalleh\FilamentShield\FilamentShield::getResources() cannot be called statically
Non-static method BezhanSalleh\FilamentShield\FilamentShield::getResources() cannot be called statically
I don't feel comfrotable amending the code to remove the static method. For context I am also using the new Panel features in Filament v3.
7 replies