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:
2025-07-29 15:33:36 +05:00
parent c7e01f404d
commit a1826ae53c
18 changed files with 226 additions and 0 deletions

View File

@@ -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();
}
}