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,58 @@
<?php
declare(strict_types=1);
namespace App\Filament\Support;
use Closure;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
/**
* Renders one tab per supported locale for a model's translatable fields.
*
* This leans on how spatie/laravel-translatable already behaves rather than
* adding a translation layer of its own: `toArray()` hands Filament the full
* locale => value map, and assigning that map back through `setAttribute`
* writes each translation. So a field whose state path is "title.ca" hydrates
* and saves the Catalan translation with no extra wiring.
*/
final class TranslatableTabs
{
/**
* @param Closure(string $locale, bool $isDefault): array<int, mixed> $fields
* Receives the locale code and whether it is the primary one,
* and returns the components for that tab.
*/
public static function make(Closure $fields, ?string $label = null): Tabs
{
$default = (string) config('locales.default');
$tabs = [];
foreach (config('locales.supported') as $locale => $meta) {
$tabs[] = Tab::make($locale)
->label(trim(($meta['flag'] ?? '').' '.($meta['native'] ?? $locale)))
// Marks the primary language, the one every other tab falls
// back to when left empty.
->badge($locale === $default ? '★' : null)
->schema($fields($locale, $locale === $default));
}
$tabs = Tabs::make($label ?? __('panel.pages.fields.translations'))
->tabs($tabs)
->columnSpanFull();
// Open the tab for the language the admin is currently working in.
return $tabs->persistTabInQueryString('locale_tab');
}
/**
* Suffix for a field label inside a locale tab, e.g. "Título (Català)".
* Useful when a field sits outside the tabs but still targets one locale.
*/
public static function suffix(string $locale): string
{
return (string) (config("locales.supported.{$locale}.native") ?? $locale);
}
}