Files
landing-api/app/Filament/Resources/Applications/Pages/ViewApplication.php
Josep Piguillem 3897113313 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>
2026-08-19 17:55:27 +02:00

69 lines
2.6 KiB
PHP

<?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(),
];
}
}