Add cross-organisation admin API endpoints behind role:super_admin middleware: - AdminOrganisationController: CRUD with search, filter, billing_status management - AdminUserController: user management with role assignment across orgs - AdminStatsController: platform-wide aggregate statistics - AdminActivityLogController: filterable activity log viewer - AdminImpersonationController + ImpersonationService: user impersonation with token-based session management and activity logging - BillingStatus enum, form requests, API resources, 23 feature tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Resources\Admin;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
final class AdminUserResource extends JsonResource
|
|
{
|
|
public function toArray(Request $request): array
|
|
{
|
|
return [
|
|
'id' => $this->id,
|
|
'first_name' => $this->first_name,
|
|
'last_name' => $this->last_name,
|
|
'full_name' => $this->full_name,
|
|
'email' => $this->email,
|
|
'avatar' => $this->avatar,
|
|
'timezone' => $this->timezone,
|
|
'locale' => $this->locale,
|
|
'email_verified_at' => $this->email_verified_at?->toIso8601String(),
|
|
'created_at' => $this->created_at->toIso8601String(),
|
|
'roles' => $this->getRoleNames()->values()->all(),
|
|
'is_super_admin' => $this->hasRole('super_admin'),
|
|
'organisations' => $this->whenLoaded('organisations', fn () =>
|
|
$this->organisations->map(fn ($org) => [
|
|
'id' => $org->id,
|
|
'name' => $org->name,
|
|
'slug' => $org->slug,
|
|
'role' => $org->pivot->role,
|
|
])
|
|
),
|
|
];
|
|
}
|
|
}
|