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

@@ -4,6 +4,7 @@ namespace App\Filament\Resources;
use App\Filament\Resources\CommentResource\Pages;
use App\Models\Comment;
use App\Models\UserRole;
use Filament\Forms;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
@@ -93,4 +94,9 @@ class CommentResource extends Resource
'edit' => Pages\EditComment::route('/{record}/edit'),
];
}
public static function canViewAny(): bool
{
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
}
}