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:
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\AboutSettings;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -245,4 +246,9 @@ class AboutPageSettings extends SettingsPage
|
||||
{
|
||||
return 'Manage the content sections of the About Us page.';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\ContactSettings;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -84,4 +85,9 @@ class ContactPageSettings extends SettingsPage
|
||||
{
|
||||
return 'Manage the contact form details, contact information, and map embed.';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\HomeSettings;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -292,4 +293,9 @@ class HomePageSettings extends SettingsPage
|
||||
{
|
||||
return 'Manage the homepage hero section, background video, and call-to-action content.';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\SiteSettings;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\SettingsPage;
|
||||
@@ -168,4 +169,9 @@ class ManageSite extends SettingsPage
|
||||
{
|
||||
return 'Manage your website\'s general configuration';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Settings\SiteSocialSettings;
|
||||
use App\Models\UserRole;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\SettingsPage;
|
||||
@@ -77,4 +78,9 @@ class ManageSiteSocialSettings extends SettingsPage
|
||||
{
|
||||
return 'Manage your social media profiles and sharing options';
|
||||
}
|
||||
|
||||
public static function canView(): bool
|
||||
{
|
||||
return auth()->user()->role === UserRole::ADMIN || auth()->user()->role === UserRole::MANAGER;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user