You've already forked Atomcms-edit
56 lines
1.5 KiB
PHP
Executable File
56 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Hotel\BadgeTextEditors\Pages;
|
|
|
|
use App\Filament\Resources\Hotel\BadgeTextEditors\BadgeTextEditorResource;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Log;
|
|
use PDOException;
|
|
|
|
class EditBadgeTextEditor extends EditRecord
|
|
{
|
|
#[\Override]
|
|
protected static string $resource = BadgeTextEditorResource::class;
|
|
|
|
#[\Override]
|
|
protected function getActions(): array
|
|
{
|
|
return [DeleteAction::make()];
|
|
}
|
|
|
|
#[\Override]
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
return $data;
|
|
}
|
|
|
|
protected function afterSave(): void {}
|
|
|
|
#[\Override]
|
|
protected function handleRecordUpdate(Model $record, array $data): Model
|
|
{
|
|
try {
|
|
return parent::handleRecordUpdate($record, $data);
|
|
} catch (PDOException $e) {
|
|
if ($e->getCode() === '23000') {
|
|
Log::error('Duplicate badge key error: ' . $e->getMessage());
|
|
|
|
Notification::make()
|
|
->title('Duplicate Badge Key')
|
|
->body('The badge key already exists. Please use a unique badge key.')
|
|
->danger()
|
|
->persistent()
|
|
->send();
|
|
|
|
return $record;
|
|
}
|
|
throw $e;
|
|
}
|
|
}
|
|
}
|