add role permission logic

This commit is contained in:
root
2026-03-10 17:11:48 -04:00
parent abebe0d9c0
commit c235fd2170
40 changed files with 1896 additions and 838 deletions
@@ -0,0 +1,25 @@
<?php
namespace App\Http\Resources\Roles;
use Illuminate\Http\Resources\Json\JsonResource;
class UserWithRolesResource extends JsonResource
{
public function toArray($request): array
{
$roles = $this['roles'] ?? [];
if (is_string($roles)) {
$roles = array_filter(array_map('trim', explode(',', $roles)));
}
return [
'id' => (int) ($this['id'] ?? 0),
'firstname' => (string) ($this['firstname'] ?? ''),
'lastname' => (string) ($this['lastname'] ?? ''),
'email' => (string) ($this['email'] ?? ''),
'account_id' => (string) ($this['account_id'] ?? ''),
'roles' => array_values(array_filter($roles)),
];
}
}