singleloginsystem/app/Data/Role/RoleUserData.php
= 5a593ffdb5 Feat: assign users to role and show users on list
- Added DTOs (`AssignUsersToRoleData`, `RoleUserData`, `UserSelectData`) for user-role operations and UI data mapping.
- Updated `RoleService` and `AppRoleService` with methods for user-role assignment, detachment, retrieval, and search.
- Enhanced Blade views and Livewire components to support user-role management in "Roles and Apps."
- Adjusted `Role`, `User`, and related models to incorporate Spatie roles and permissions support.
- Improved UI with search and selection capabilities for assigning users to roles.
2026-05-19 12:24:42 +00:00

30 lines
573 B
PHP

<?php
declare(strict_types=1);
namespace App\Data\Role;
use App\Models\User;
use Spatie\LaravelData\Data;
final class RoleUserData extends Data
{
public function __construct(
public int $id,
public string $name,
public string $initials = '',
) {}
/**
* Intercept the Eloquent model and map it to the DTO properties.
*/
public static function fromModel(User $user): self
{
return new self(
id: $user->id,
name: $user->name,
initials: $user->initials()
);
}
}