mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
admin add claim
This commit is contained in:
@@ -3,10 +3,34 @@
|
||||
namespace App\Filament\Resources\System\ExamResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\ExamResource;
|
||||
use App\Repositories\ExamRepository;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateExam extends CreateRecord
|
||||
{
|
||||
protected static string $resource = ExamResource::class;
|
||||
|
||||
public function create(bool $another = false): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
// dd($data);
|
||||
$examRep = new ExamRepository();
|
||||
try {
|
||||
$examRep->store($data);
|
||||
$this->notify('success', $this->getCreatedNotificationMessage());
|
||||
if ($another) {
|
||||
// Ensure that the form record is anonymized so that relationships aren't loaded.
|
||||
$this->form->model($this->record::class);
|
||||
$this->record = null;
|
||||
|
||||
$this->fillForm();
|
||||
|
||||
return;
|
||||
}
|
||||
$this->redirect($this->getRedirectUrl());
|
||||
} catch (\Exception $exception) {
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\System\ExamResource\Pages;
|
||||
|
||||
use App\Filament\Resources\System\ExamResource;
|
||||
use App\Repositories\ExamRepository;
|
||||
use Filament\Pages\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
@@ -16,4 +17,17 @@ class EditExam extends EditRecord
|
||||
Actions\DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
public function save(bool $shouldRedirect = true): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
$examRep = new ExamRepository();
|
||||
try {
|
||||
$examRep->update($data, $this->record->id);
|
||||
$this->notify('success', $this->getSavedNotificationMessage());
|
||||
$this->redirect($this->getResource()::getUrl('index'));
|
||||
} catch (\Exception $exception) {
|
||||
$this->notify('danger', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class ListExams extends PageList
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [
|
||||
// Actions\CreateAction::make(),
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user