Each field's original sits beside the field to write, and a translation that fell behind shows what the original said when it was translated and what it says now, word by word. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Pages\Pages;
|
|
|
|
use App\Enums\PageStatus;
|
|
use App\Filament\Concerns\WarnsOfConcurrentEditing;
|
|
use App\Filament\Resources\Pages\PageResource;
|
|
use App\Filament\Support\DuplicateAction;
|
|
use App\Filament\Support\PreviewAction;
|
|
use App\Filament\Support\TranslateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\ForceDeleteAction;
|
|
use Filament\Actions\RestoreAction;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditPage extends EditRecord
|
|
{
|
|
use WarnsOfConcurrentEditing;
|
|
|
|
protected static string $resource = PageResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
// Seeing it on the real site without leaving the form.
|
|
PreviewAction::for('page'),
|
|
DuplicateAction::make(),
|
|
TranslateAction::make(),
|
|
DeleteAction::make(),
|
|
ForceDeleteAction::make(),
|
|
RestoreAction::make(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
if (($data['status'] ?? null) === PageStatus::Published->value && blank($data['published_at'] ?? null)) {
|
|
$data['published_at'] = now();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|