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:
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SettingsResource\Pages;
|
||||
|
||||
use App\Filament\Concerns\WarnsOfConcurrentEditing;
|
||||
use App\Filament\Resources\SettingsResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditSettings extends EditRecord
|
||||
{
|
||||
use WarnsOfConcurrentEditing;
|
||||
|
||||
protected static string $resource = SettingsResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// Settings should not be deleted from the UI
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SettingsResource\Pages;
|
||||
|
||||
use App\Filament\Resources\SettingsResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListSettings extends ListRecords
|
||||
{
|
||||
protected static string $resource = SettingsResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// Settings are managed individually, no bulk create
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SettingsResource\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SettingsForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
Section::make(__('panel.settings.sections.general'))
|
||||
->schema([
|
||||
TextInput::make('key')
|
||||
->label(__('panel.settings.fields.key'))
|
||||
->disabled()
|
||||
->columnSpanFull(),
|
||||
|
||||
/*
|
||||
* Raw JSON rather than a key/value editor.
|
||||
*
|
||||
* A setting holds whatever it holds: `site.maintenance` is
|
||||
* a map containing another map of translations. A
|
||||
* key/value grid can only show one flat level, so it would
|
||||
* render the nested part as text and write that text back
|
||||
* on save — quietly destroying every translation of the
|
||||
* maintenance notice.
|
||||
*
|
||||
* Showing the value as it really is cannot lie about it,
|
||||
* and the `json` rule means a typo is refused rather than
|
||||
* stored.
|
||||
*/
|
||||
Textarea::make('value')
|
||||
->label(__('panel.settings.fields.value'))
|
||||
->helperText(__('panel.settings.fields.value_hint'))
|
||||
->rows(12)
|
||||
->columnSpanFull()
|
||||
->extraInputAttributes(['class' => 'font-mono text-sm'])
|
||||
->rule('json')
|
||||
->formatStateUsing(fn (mixed $state): string => json_encode(
|
||||
$state,
|
||||
JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES,
|
||||
) ?: 'null')
|
||||
->dehydrateStateUsing(fn (?string $state): mixed => json_decode(
|
||||
(string) $state,
|
||||
associative: true,
|
||||
)),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\SettingsResource\Tables;
|
||||
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ViewColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class SettingsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('key')
|
||||
->label(__('panel.settings.fields.key'))
|
||||
->searchable()
|
||||
->sortable()
|
||||
->weight('medium')
|
||||
->fontFamily('mono'),
|
||||
|
||||
// A ViewColumn is a bare column: it has no `wrap()`, and does
|
||||
// not need one — the view below does its own wrapping.
|
||||
ViewColumn::make('value')
|
||||
->label(__('panel.settings.fields.value'))
|
||||
->view('filament.tables.columns.json-value'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user