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:
@@ -4,6 +4,7 @@ namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\BrandResource\Pages;
|
||||
use App\Models\Brand;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
@@ -79,4 +80,9 @@ class BrandResource extends Resource
|
||||
'index' => Pages\ManageBrands::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user