- 'Use' permission of apps now synced with Role - Added `PermissionData` DTO for standardized permission transformation. - Expanded `AppsPermissionService` with `getAllPermissions` method for retrieving connected app permissions. - Updated `AppRoleService` with methods for assigning and revoking app permissions to roles (`assignAppPermissionsRole`, `removeAppPermissionsRole`). - Introduced `AppPermission::type` method for extracting permission type from names. - Refined role and app interaction logic, including proper slug generation and app-role association.
30 lines
635 B
PHP
30 lines
635 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 static function fromModel(Permission $permission): self
|
|
{
|
|
return new self(
|
|
id: $permission->id,
|
|
name: $permission->name,
|
|
type: AppPermission::type($permission->name),
|
|
);
|
|
|
|
}
|
|
}
|