*/ 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 ?? [], ]; } }