- Update API: events, users, policies, routes, resources, migrations - Remove deprecated models/resources (customers, setlists, invitations, etc.) - Refresh admin app and docs; remove apps/band Made-with: Cursor
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Api\V1;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class UserResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'name' => $this->name,
|
|
'email' => $this->email,
|
|
'roles' => $this->getRoleNames()->values()->all(),
|
|
'timezone' => $this->timezone,
|
|
'locale' => $this->locale,
|
|
'avatar' => $this->avatar,
|
|
'email_verified_at' => $this->email_verified_at?->toIso8601String(),
|
|
'created_at' => $this->created_at->toIso8601String(),
|
|
'updated_at' => $this->updated_at->toIso8601String(),
|
|
'organisations' => $this->whenLoaded('organisations', fn () =>
|
|
$this->organisations->map(fn ($org) => [
|
|
'id' => $org->id,
|
|
'name' => $org->name,
|
|
'slug' => $org->slug,
|
|
'role' => $org->pivot->role,
|
|
])
|
|
),
|
|
'event_roles' => $this->whenLoaded('events', fn () =>
|
|
$this->events->map(fn ($event) => [
|
|
'event_id' => $event->id,
|
|
'event_name' => $event->name,
|
|
'role' => $event->pivot->role,
|
|
])
|
|
),
|
|
];
|
|
}
|
|
}
|