Files
nexusphp/app/Filament/Resources/System/ExamResource/Pages/EditExam.php

34 lines
994 B
PHP
Raw Normal View History

2022-06-27 01:39:01 +08:00
<?php
namespace App\Filament\Resources\System\ExamResource\Pages;
use App\Filament\Resources\System\ExamResource;
2022-07-02 15:08:23 +08:00
use App\Repositories\ExamRepository;
2022-06-27 01:39:01 +08:00
use Filament\Pages\Actions;
use Filament\Resources\Pages\EditRecord;
class EditExam extends EditRecord
{
protected static string $resource = ExamResource::class;
2024-12-25 23:09:07 +08:00
protected function getHeaderActions(): array
2022-06-27 01:39:01 +08:00
{
return [
Actions\DeleteAction::make(),
];
}
2022-07-02 15:08:23 +08:00
2024-12-25 23:09:07 +08:00
public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotification = true): void
2022-07-02 15:08:23 +08:00
{
$data = $this->form->getState();
$examRep = new ExamRepository();
try {
$this->record = $examRep->update($data, $this->record->id);
2022-12-01 00:45:22 +08:00
$this->notify('success', $this->getSavedNotificationTitle());
2022-07-02 15:08:23 +08:00
$this->redirect($this->getResource()::getUrl('index'));
} catch (\Exception $exception) {
$this->notify('danger', $exception->getMessage());
}
}
2022-06-27 01:39:01 +08:00
}