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:
2026-08-19 17:55:27 +02:00
commit 3897113313
534 changed files with 64050 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Category;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Category
*/
class CategoryResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = $request->query(config('locales.query_parameter')) ?? app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
...TranslatablePayload::resolve($this->resource, $this->translatable, $locale),
'color' => $this->color,
'position' => $this->position,
'is_visible' => $this->is_visible,
'pages_count' => $this->whenCounted('pages'),
'created_at' => $this->created_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
'translations' => $this->when(
in_array('translations', explode(',', (string) $request->query('with')), true),
fn () => TranslatablePayload::all($this->resource, $this->translatable),
),
];
}
}

View File

@@ -0,0 +1,61 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Page;
use App\Support\ImagePayload;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Page
*/
class PageResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = $request->query(config('locales.query_parameter')) ?? app()->getLocale();
$resolved = TranslatablePayload::resolve($this->resource, $this->translatable, $locale);
return [
'id' => $this->id,
'locale' => $locale,
...$resolved,
'status' => $this->status->value,
'status_label' => $this->status->getLabel(),
'is_featured' => $this->is_featured,
// The stored path, because this is the editing API and it is
// what a client PATCHes back. What was *derived* from it travels
// alongside rather than replacing it.
'featured_image' => $this->featured_image,
'featured_image_media' => ImagePayload::make(
$this->featured_image,
$this->resource->relationLoaded('featuredMedia') ? $this->resource->getRelation('featuredMedia') : null,
$resolved['featured_image_alt'] ?? null,
),
'published_at' => $this->published_at?->toIso8601String(),
'unpublish_at' => $this->unpublish_at?->toIso8601String(),
'created_at' => $this->created_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
'deleted_at' => $this->deleted_at?->toIso8601String(),
'category' => CategoryResource::make($this->whenLoaded('category')),
'author' => UserResource::make($this->whenLoaded('author')),
// Opt-in: `?with=translations` returns every language at once,
// which is what a translation UI needs and a page renderer does not.
'translations' => $this->when(
in_array('translations', explode(',', (string) $request->query('with')), true),
fn () => TranslatablePayload::all($this->resource, $this->translatable),
),
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Call;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Call
*/
class PublicCallResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
...TranslatablePayload::resolve(
$this->resource,
['title', 'slug', 'description', 'what_you_get'],
$locale,
),
'status' => $this->status->value,
// The numbers that let someone decide in ten seconds. Time is the
// scarce resource here, not money.
'hours_per_week' => $this->hours_per_week,
'duration_weeks' => $this->duration_weeks,
'total_hours' => $this->totalHours(),
'seniority' => $this->seniority,
'closes_at' => $this->closes_at?->toDateString(),
'project' => PublicProjectResource::make($this->whenLoaded('project')),
'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')),
'alternates' => SiteUrls::alternates($this->resource, 'call'),
'path' => SiteUrls::alternates($this->resource, 'call')[$locale] ?? null,
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Category;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Category
*/
class PublicCategoryResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
...TranslatablePayload::resolve($this->resource, $this->translatable, app()->getLocale()),
'color' => $this->color,
'position' => $this->position,
'pages_count' => $this->whenCounted('pages'),
];
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Client;
use App\Support\ImagePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Client
*/
class PublicClientResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
'sector' => $this->getTranslation('sector', $locale, false) ?: null,
'url' => $this->url,
// The logo's alt text is the organisation's name, so there is
// nothing to type and nothing to get wrong.
'logo' => ImagePayload::make(
$this->logo,
$this->resource->relationLoaded('logoMedia') ? $this->resource->getRelation('logoMedia') : null,
$this->name,
),
'projects_count' => $this->whenCounted('projects'),
'projects' => PublicProjectResource::collection($this->whenLoaded('projects')),
];
}
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\RepositoryIssue;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin RepositoryIssue
*
* An open door for someone who has never contributed before.
*/
class PublicIssueResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'number' => $this->number,
'title' => $this->title,
'url' => $this->html_url,
'labels' => $this->labels ?? [],
'is_good_first_issue' => $this->is_good_first_issue,
'is_help_wanted' => $this->is_help_wanted,
// An issue someone has already claimed is not an invitation.
'is_available' => $this->isUnclaimed(),
'comments' => $this->comments,
'created_at' => $this->issue_created_at?->toIso8601String(),
'repository' => $this->whenLoaded('repository', fn () => [
'full_name' => $this->repository->full_name,
'url' => $this->repository->html_url,
'primary_language' => $this->repository->primary_language,
'project' => $this->repository->relationLoaded('project') && $this->repository->project
? [
'title' => $this->repository->project->getTranslation('title', app()->getLocale()),
'slug' => $this->repository->project->getTranslation('slug', app()->getLocale()),
]
: null,
]),
];
}
}

View File

@@ -0,0 +1,78 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Member;
use App\Support\ImagePayload;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Member
*
* A member's profile is the real currency a volunteer collective pays people
* in, so it carries everything needed to render a proper personal page rather
* than a bare avatar and name.
*/
class PublicMemberResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'name' => $this->name,
'slug' => $this->slug,
...TranslatablePayload::resolve($this->resource, ['headline', 'bio'], $locale),
// A portrait's description is the person's name, so there is no
// field to fill in and no way to get it wrong.
'avatar' => ImagePayload::make(
$this->avatar,
$this->resource->relationLoaded('avatarMedia') ? $this->resource->getRelation('avatarMedia') : null,
$this->avatarAlt(),
),
'github_username' => $this->github_username,
'links' => (object) ($this->links ?? []),
'is_founder' => $this->is_founder,
// Former members stay on the site with their history intact; the
// frontend decides how to present them.
'is_current' => $this->left_at === null,
'joined_at' => $this->joined_at?->toDateString(),
'left_at' => $this->left_at?->toDateString(),
'role' => $this->whenPivotLoaded('member_project', fn () => $this->pivot->role),
'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')),
'projects' => PublicProjectResource::collection($this->whenLoaded('projects')),
'alternates' => $this->memberAlternates(),
'path' => SiteUrls::path('member', $locale, $this->slug),
];
}
/**
* A member's slug is a single string rather than a translated map, so the
* same slug is valid in every locale — only the path prefix changes.
*
* @return array<string, string>
*/
protected function memberAlternates(): array
{
return collect(array_keys(config('locales.supported')))
->mapWithKeys(fn (string $locale) => [
$locale => SiteUrls::path('member', $locale, $this->slug),
])
->all();
}
}

View File

@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Page;
use App\Support\ImagePayload;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Page
*/
class PublicPageResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
/*
* An explicit list rather than the model's whole translatable
* set. `featured_image_alt` is in that set, and resolving it here
* put the alt text at the top level as well as inside
* `featured_image`, where the specification says it lives and
* where an <img> needs it. Two names for one string is how a
* frontend ends up reading the one that later turns out to be the
* accidental one.
*/
...TranslatablePayload::resolve(
$this->resource,
['title', 'slug', 'excerpt', 'body', 'meta_title', 'meta_description'],
$locale,
),
'status' => $this->status->value,
'is_featured' => $this->is_featured,
'featured_image' => ImagePayload::make(
$this->featured_image,
$this->resource->relationLoaded('featuredMedia') ? $this->resource->getRelation('featuredMedia') : null,
$this->getTranslation('featured_image_alt', $locale, false) ?: null,
),
'published_at' => $this->published_at?->toIso8601String(),
// So a cache downstream can expire when the content does, rather
// than holding a notice that is no longer true.
'unpublish_at' => $this->unpublish_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
'category' => PublicCategoryResource::make($this->whenLoaded('category')),
// Lets the frontend emit correct hreflang tags. Only locales that
// actually have a translation appear.
'alternates' => SiteUrls::alternates($this->resource, 'page'),
'path' => SiteUrls::alternates($this->resource, 'page')[$locale] ?? null,
];
}
}

View File

@@ -0,0 +1,141 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Media;
use App\Models\Project;
use App\Support\ImagePayload;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Project
*/
class PublicProjectResource extends JsonResource
{
/**
* Whether to include the long-form fields. Listings stay light; the detail
* endpoint opts in.
*/
protected bool $detailed = false;
public function detailed(bool $detailed = true): static
{
$this->detailed = $detailed;
return $this;
}
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
$summary = TranslatablePayload::resolve($this->resource, ['title', 'slug', 'tagline'], $locale);
return [
'id' => $this->id,
'locale' => $locale,
...$summary,
'status' => $this->status->value,
'is_featured' => $this->is_featured,
// True when flagged directly, or when the project carries an open
// call. Read from a count rather than the relation so a listing
// does not trigger a query per project.
'needs_help' => $this->needs_help || $this->openCallCount() > 0,
// A full image object rather than a path: the frontend needs
// width and height to reserve the box, a srcset so a phone does
// not download the original, and the alt text to be accessible.
'cover_image' => ImagePayload::make(
$this->cover_image,
$this->loadedMedia('coverMedia'),
$this->getTranslation('cover_image_alt', $locale, false) ?: null,
),
'demo_url' => $this->demo_url,
// Who the work is for. Central to a non-profit collective's story
// in a way it never is for a commercial portfolio — and now a
// record of its own, so the same organisation is the same thing on
// every project it appears in.
'client' => PublicClientResource::make($this->whenLoaded('client')),
'started_at' => $this->started_at?->toDateString(),
'ended_at' => $this->ended_at?->toDateString(),
'published_at' => $this->published_at?->toIso8601String(),
'unpublish_at' => $this->unpublish_at?->toIso8601String(),
'updated_at' => $this->updated_at?->toIso8601String(),
// The long form: the decisions and the postmortem are the content
// other developers actually read, so they are never truncated.
$this->mergeWhen($this->detailed, fn () => TranslatablePayload::resolve(
$this->resource,
['description', 'decisions', 'postmortem', 'meta_title', 'meta_description'],
$locale,
)),
// Only on the detail endpoint: a listing showing twenty projects
// has no use for every screenshot of each one.
'gallery' => $this->when(
$this->detailed && $this->resource->relationLoaded('images'),
fn () => $this->images->map(fn ($image) => [
...ImagePayload::make(
$image->path,
$image->relationLoaded('media') ? $image->media : null,
$image->getTranslation('alt', $locale, false) ?: null,
),
// Shown to everyone, unlike the alt text.
'caption' => $image->getTranslation('caption', $locale, false) ?: null,
])->all(),
),
'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')),
'services' => PublicServiceResource::collection($this->whenLoaded('services')),
'testimonials' => PublicTestimonialResource::collection($this->whenLoaded('testimonials')),
'talks' => PublicTalkResource::collection($this->whenLoaded('talks')),
'members' => PublicMemberResource::collection($this->whenLoaded('members')),
'lead' => PublicMemberResource::make($this->whenLoaded('lead')),
'calls' => PublicCallResource::collection($this->whenLoaded('calls')),
// Live repository activity — the part that keeps the site looking
// alive without anyone maintaining it.
'repositories' => PublicRepositoryResource::collection($this->whenLoaded('repositories')),
'alternates' => SiteUrls::alternates($this->resource, 'project'),
'path' => SiteUrls::alternates($this->resource, 'project')[$locale] ?? null,
];
}
/**
* The media row when the caller loaded it, and null otherwise — never a
* lazy load, because this runs once per row in a listing.
*/
protected function loadedMedia(string $relation): ?Media
{
return $this->resource->relationLoaded($relation)
? $this->resource->getRelation($relation)
: null;
}
/**
* Open calls attached to this project, from whichever source the caller
* already loaded — never by lazy-loading the relation.
*/
protected function openCallCount(): int
{
if ($this->resource->relationLoaded('calls')) {
return $this->calls->count();
}
return (int) ($this->resource->open_calls_count ?? 0);
}
}

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Repository;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Repository
*/
class PublicRepositoryResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'provider' => $this->provider->value,
'full_name' => $this->full_name,
'url' => $this->html_url,
'description' => $this->description,
'primary_language' => $this->primary_language,
'languages' => (object) ($this->languages ?? []),
'topics' => $this->topics ?? [],
'license' => $this->license,
'stars' => $this->stars,
'forks' => $this->forks,
'contributors_count' => $this->contributors_count,
'open_issues_count' => $this->open_issues_count,
'is_archived' => $this->is_archived,
// Lets the frontend avoid presenting dead work as live.
'is_dormant' => $this->isDormant(),
'pushed_at' => $this->pushed_at?->toIso8601String(),
'synced_at' => $this->last_synced_at?->toIso8601String(),
'good_first_issues' => PublicIssueResource::collection($this->whenLoaded('goodFirstIssues')),
'issues' => PublicIssueResource::collection($this->whenLoaded('issues')),
];
}
}

View File

@@ -0,0 +1,62 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Service;
use App\Support\SiteUrls;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Service
*/
class PublicServiceResource extends JsonResource
{
protected bool $detailed = false;
public function detailed(bool $detailed = true): static
{
$this->detailed = $detailed;
return $this;
}
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'locale' => $locale,
...TranslatablePayload::resolve($this->resource, ['title', 'slug', 'tagline'], $locale),
'icon' => $this->icon,
'is_featured' => $this->is_featured,
'position' => $this->position,
'updated_at' => $this->updated_at?->toIso8601String(),
$this->mergeWhen($this->detailed, fn () => TranslatablePayload::resolve(
$this->resource,
['description', 'meta_title', 'meta_description'],
$locale,
)),
// The work that backs the offer. Without it a service is a
// promise, which is why it travels with it rather than being
// something the frontend has to go and ask for.
'projects' => PublicProjectResource::collection($this->whenLoaded('projects')),
'technologies' => PublicTechnologyResource::collection($this->whenLoaded('technologies')),
'testimonials' => PublicTestimonialResource::collection($this->whenLoaded('testimonials')),
'alternates' => SiteUrls::alternates($this->resource, 'service'),
'path' => SiteUrls::alternates($this->resource, 'service')[$locale] ?? null,
];
}
}

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Talk;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Talk
*/
class PublicTalkResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
// Not translated: it is the name of a talk that was given once, in
// one language. `language` says which.
'title' => $this->title,
'language' => $this->language,
'summary' => $this->getTranslation('summary', $locale, false) ?: null,
'event' => $this->event,
'city' => $this->city,
'held_at' => $this->held_at?->toDateString(),
'video_url' => $this->video_url,
'slides_url' => $this->slides_url,
'speaker' => PublicMemberResource::make($this->whenLoaded('member')),
];
}
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Technology;
use App\Support\ImagePayload;
use App\Support\TranslatablePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Technology
*/
class PublicTechnologyResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
// Not translated: technology names are proper nouns.
'name' => $this->name,
'slug' => $this->slug,
'category' => $this->category?->value,
'color' => $this->color,
'icon' => $this->icon,
// The alt text of a logo is the name of the thing, so there is
// nothing to type and nothing to get wrong.
'logo' => ImagePayload::make(
$this->logo,
$this->resource->relationLoaded('logoMedia') ? $this->resource->getRelation('logoMedia') : null,
$this->name,
),
'website' => $this->website,
// Tech radar. `ring` is null for technologies used but not placed.
'ring' => $this->radar_ring?->value,
...TranslatablePayload::resolve($this->resource, ['description', 'radar_note'], app()->getLocale()),
'projects_count' => $this->whenCounted('projects'),
'members_count' => $this->whenCounted('members'),
];
}
}

View File

@@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\PublicApi;
use App\Models\Testimonial;
use App\Support\ImagePayload;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Testimonial
*/
class PublicTestimonialResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$locale = app()->getLocale();
return [
'id' => $this->id,
'quote' => $this->getTranslation('quote', $locale),
/*
* Whether these are the words that were actually said. A quote
* shown in a language it was not given in has been translated by
* us, and the frontend can say so — "translated from Spanish" —
* instead of pretending somebody phrased it that way.
*/
'original_locale' => $this->original_locale,
'is_original' => $this->isOriginal($locale),
'author' => [
'name' => $this->author_name,
'role' => $this->getTranslation('author_role', $locale, false) ?: null,
'avatar' => ImagePayload::make(
$this->avatar,
$this->resource->relationLoaded('avatarMedia') ? $this->resource->getRelation('avatarMedia') : null,
$this->author_name,
),
],
'given_at' => $this->given_at?->toDateString(),
'client' => PublicClientResource::make($this->whenLoaded('client')),
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Spatie\Permission\Models\Role;
/**
* @mixin Role
*/
class RoleResource extends JsonResource
{
/**
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'guard_name' => $this->guard_name,
'users_count' => $this->whenCounted('users'),
'permissions' => $this->whenLoaded(
'permissions',
fn () => $this->permissions->pluck('name')->values(),
),
'created_at' => $this->created_at?->toIso8601String(),
];
}
}

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