Add user role management: introduce UserRole enum for role definitions, implement role-based access control in various resources and pages, and enhance authorization logic in the PanelProvider for improved security and user experience.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Resources\InternshipResource\Pages;
|
||||
use App\Filament\Resources\InternshipResource\RelationManagers;
|
||||
use App\Models\Internship;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -120,4 +121,9 @@ class InternshipResource extends Resource
|
||||
'edit' => Pages\EditInternship::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user