- Added `RestrictedUserPermission` migration and model for managing user-role-permission restrictions. - Introduced `UserService`, `RoleService`, and related DTOs for handling user access, role assignments, and permission restrictions. - Created new Livewire components and Blade views for user management, including role/permission assignment modals. - Updated navigation and routing to include the "Users" section under "Access Manager." - Enhanced `RoleService` with methods for retrieving permissions and managing role-user interactions. - Improved UI with permission toggles and streamlined selection features for better user-role management.
36 lines
957 B
PHP
36 lines
957 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Data\User;
|
|
|
|
use App\Data\Role\RoleData;
|
|
use App\Models\User;
|
|
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
|
use Spatie\LaravelData\{Data, DataCollection};
|
|
|
|
final class UserIndexData extends Data
|
|
{
|
|
public function __construct(
|
|
public int $id,
|
|
public string $name,
|
|
public string $email,
|
|
public string $initials,
|
|
#[DataCollectionOf(class: RoleData::class)]
|
|
public ?DataCollection $roles = null,
|
|
public ?array $restrictedPermissionIds = null,
|
|
) {}
|
|
|
|
public static function fromModel(User $user)
|
|
{
|
|
return new self(
|
|
id: $user->id,
|
|
name: $user->name,
|
|
email: $user->email,
|
|
initials: $user->initials(),
|
|
roles: RoleData::collect($user->roles, DataCollection::class),
|
|
restrictedPermissionIds: $user->restrictedPermissions->pluck('id')->toArray()
|
|
);
|
|
}
|
|
}
|