Eine Fassung bleibt nummeriert und kann deaktiviert werden. Beschreibung und fachliche Säulen gehören zum Medium und legen keine neue Fassung an. Co-authored-by: Cursor <cursoragent@cursor.com>
59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Pillars\Pages;
|
|
|
|
use App\Domain\Catalog\DomainRuleException;
|
|
use App\Domain\Catalog\Pillar;
|
|
use App\Domain\Catalog\PillarService;
|
|
use App\Filament\Resources\Pillars\PillarResource;
|
|
use App\Filament\Support\ReportsDomainRules;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
use Filament\Support\Exceptions\Halt;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class EditPillar extends EditRecord
|
|
{
|
|
use ReportsDomainRules;
|
|
|
|
protected static string $resource = PillarResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('delete')
|
|
->label('Löschen')
|
|
->color('danger')
|
|
->requiresConfirmation()
|
|
->action(function (): void {
|
|
/** @var Pillar $pillar */
|
|
$pillar = $this->getRecord();
|
|
$deleted = false;
|
|
$this->report(function () use ($pillar, &$deleted): void {
|
|
app(PillarService::class)->delete($pillar);
|
|
$deleted = true;
|
|
}, 'Die Säule ist gelöscht.');
|
|
|
|
if ($deleted) {
|
|
$this->redirect(PillarResource::getUrl('index'));
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function handleRecordUpdate(Model $record, array $data): Model
|
|
{
|
|
/** @var Pillar $record */
|
|
try {
|
|
app(PillarService::class)->rename($record, $data['name']);
|
|
} catch (DomainRuleException $exception) {
|
|
Notification::make()->title($exception->getMessage())->danger()->send();
|
|
|
|
throw new Halt;
|
|
}
|
|
|
|
return $record;
|
|
}
|
|
}
|