Initial commit: Pireon Admin — headless admin panel and public API
Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
46
app/Http/Resources/UserResource.php
Normal file
46
app/Http/Resources/UserResource.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/**
|
||||
* @mixin User
|
||||
*/
|
||||
class UserResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
// The identity server's id for this person, for clients that also
|
||||
// talk to oauth.pireon.dev directly.
|
||||
'oauth_id' => $this->oauth_id,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
'avatar_url' => $this->avatar_url,
|
||||
'locale' => $this->locale,
|
||||
'is_active' => $this->is_active,
|
||||
'last_login_at' => $this->last_login_at?->toIso8601String(),
|
||||
'created_at' => $this->created_at?->toIso8601String(),
|
||||
|
||||
// Local authorisation — what this person may do in *this* app.
|
||||
'roles' => $this->whenLoaded('roles', fn () => $this->roles->pluck('name')->values()),
|
||||
'permissions' => $this->when(
|
||||
$request->routeIs('api.v1.me'),
|
||||
fn () => $this->getAllPermissions()->pluck('name')->values(),
|
||||
),
|
||||
|
||||
// Roles reported by the identity server. Informational only: they
|
||||
// grant nothing here.
|
||||
'remote_roles' => $this->remote_roles ?? [],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user