- Added `priority`-based access logic to restrict role and user management actions. - Introduced `Permission Manager` UI and routes for permission access control. - Updated `RoleService` and `AppRoleService` to include `visible` scope for priority filtering. - Enhanced seeding to assign priorities to default roles and ensure proper hierarchy. - Updated sidebar, routes, and data structure to handle new permission enums and resource segmentation. - Improved UI components to dynamically restrict visibility and actions based on role priority.
34 lines
827 B
PHP
34 lines
827 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Data\Permissions;
|
|
|
|
use App\Enums\ConnectedAppPermissonEnum;
|
|
use App\Helpers\AppPermission;
|
|
use Spatie\LaravelData\Data;
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
class PermissionData extends Data
|
|
{
|
|
public function __construct(
|
|
public int $id,
|
|
public string $name,
|
|
public ?ConnectedAppPermissonEnum $type,
|
|
public string $resource = 'general',
|
|
) {}
|
|
|
|
public static function fromModel(Permission $permission): self
|
|
{
|
|
$parts = explode(':', $permission->name);
|
|
$resource = count($parts) > 1 ? $parts[0] : 'general';
|
|
|
|
return new self(
|
|
id: $permission->id,
|
|
name: $permission->name,
|
|
type: AppPermission::type($permission->name),
|
|
resource: $resource,
|
|
);
|
|
}
|
|
}
|