- Replaced `AccessManager`, `Apps`, and `Settings` enums with modular enums like `RoleAndAppsPermissionEnum`, `AppPermissionEnum`, etc. - Updated route, view, Livewire components, and tests to use new modular enums. - Enhanced `DefaultRoleWithPermissionSeeder` and `PermissionSeeder` with updated enums. - Added README in the Enums/Permissions directory to explain usage and naming conventions. - Refactored dashboard sidebar and route definitions for better enum-based permission handling. - Improved test coverage to validate new permission enums functionality.
1.0 KiB
1.0 KiB
Permissions Enums
This directory contains all the permissions enums. Spatie/laravel-permission uses these enums to check permissions. Any Permission enum added here will be automatically added to the database, when the PermissionSeeder is run, no need to add it manually. This is done via Reflection API.
Only string backed are supported.
Value format of Enum
We are following the convention of scope:resource:action .
File name of the enum should be same as the scope name, and Enum value should be in the format of resource:action.
Example: UserPermissionEnum.php
namespace App\Enums\Permissions;
enum UserPermissionEnum:string
{
case Create = 'user:create';
case Read = 'user:read';
case Update = 'user:update';
case Delete = 'user:delete';
}
// using the enum makes straight forward permission check
$user->can(UserPermissionEnum::Create);
@can(UserPermissionEnum::Create);