You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+55
@@ -0,0 +1,55 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user