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:
@@ -15,6 +15,7 @@ use Filament\Tables;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class SuccessResource extends Resource
|
||||
{
|
||||
@@ -112,4 +113,34 @@ class SuccessResource extends Resource
|
||||
'edit' => Pages\EditSuccess::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return auth()->user()->can('manage-news-and-success');
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return auth()->user()->can('manage-news-and-success');
|
||||
}
|
||||
|
||||
public static function canEdit(mixed $record): bool
|
||||
{
|
||||
return auth()->user()->can('manage-news-and-success');
|
||||
}
|
||||
|
||||
public static function canDelete(mixed $record): bool
|
||||
{
|
||||
return auth()->user()->can('manage-news-and-success');
|
||||
}
|
||||
|
||||
public static function canDeleteAny(): bool
|
||||
{
|
||||
return auth()->user()->can('manage-news-and-success');
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->withoutGlobalScopes();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user