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,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Applications\Pages;
|
||||
|
||||
use App\Enums\ApplicationKind;
|
||||
use App\Enums\ApplicationStatus;
|
||||
use App\Filament\Resources\Applications\ApplicationResource;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListApplications extends ListRecords
|
||||
{
|
||||
protected static string $resource = ApplicationResource::class;
|
||||
|
||||
/**
|
||||
* Tabs rather than filters for the two questions asked most often: who is
|
||||
* still waiting, and who is offering time versus asking for it.
|
||||
*
|
||||
* @return array<string, Tab>
|
||||
*/
|
||||
public function getTabs(): array
|
||||
{
|
||||
return [
|
||||
'pending' => Tab::make(__('panel.applications.tabs.pending'))
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->pending())
|
||||
->badge(ApplicationResource::getModel()::query()->pending()->count())
|
||||
->badgeColor('warning'),
|
||||
|
||||
'contribute' => Tab::make(__('panel.applications.tabs.contribute'))
|
||||
->modifyQueryUsing(fn (Builder $query) => $query
|
||||
->where('kind', ApplicationKind::Contribute)
|
||||
->notSpam()),
|
||||
|
||||
'request' => Tab::make(__('panel.applications.tabs.request'))
|
||||
->modifyQueryUsing(fn (Builder $query) => $query
|
||||
->where('kind', ApplicationKind::Request)
|
||||
->notSpam()),
|
||||
|
||||
'all' => Tab::make(__('panel.applications.tabs.all')),
|
||||
|
||||
'spam' => Tab::make(__('panel.applications.tabs.spam'))
|
||||
->modifyQueryUsing(fn (Builder $query) => $query
|
||||
->where('status', ApplicationStatus::Spam)),
|
||||
];
|
||||
}
|
||||
|
||||
public function getDefaultActiveTab(): string|int|null
|
||||
{
|
||||
return 'pending';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Applications\Pages;
|
||||
|
||||
use App\Filament\Resources\Applications\ApplicationResource;
|
||||
use App\Filament\Resources\Applications\Tables\ApplicationsTable;
|
||||
use App\Models\Application;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ForceDeleteAction;
|
||||
use Filament\Actions\RestoreAction;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewApplication extends ViewRecord
|
||||
{
|
||||
protected static string $resource = ApplicationResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
// Answering is the point of the record, so the reply is the first
|
||||
// button rather than something to copy out of the page.
|
||||
Action::make('reply')
|
||||
->label(__('panel.applications.actions.reply'))
|
||||
->icon('heroicon-o-envelope')
|
||||
->color('primary')
|
||||
->url(fn (Application $record) => 'mailto:'.$record->email.'?subject='
|
||||
.rawurlencode(__('panel.applications.reply_subject', [
|
||||
'subject' => $record->subject(),
|
||||
])))
|
||||
->openUrlInNewTab(),
|
||||
|
||||
Action::make('notes')
|
||||
->label(__('panel.applications.actions.notes'))
|
||||
->icon('heroicon-o-pencil-square')
|
||||
->color('gray')
|
||||
->authorize('update')
|
||||
->schema([
|
||||
Textarea::make('notes')
|
||||
->label(__('panel.applications.fields.notes'))
|
||||
->helperText(__('panel.applications.fields.notes_hint'))
|
||||
->rows(6),
|
||||
])
|
||||
->fillForm(fn (Application $record) => ['notes' => $record->notes])
|
||||
->action(function (Application $record, array $data): void {
|
||||
// Notes are outside the model's fillable list on purpose —
|
||||
// nothing arriving from the public form may ever land in
|
||||
// them — so they are written explicitly here.
|
||||
$record->forceFill(['notes' => $data['notes']])->save();
|
||||
|
||||
Notification::make()
|
||||
->title(__('panel.applications.saved'))
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
|
||||
...ApplicationsTable::statusActions(),
|
||||
|
||||
DeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user