mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
[admin] delete exam also delete user and progress
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Filament\OptionsTrait;
|
|||||||
use App\Filament\Resources\System\ExamResource\Pages;
|
use App\Filament\Resources\System\ExamResource\Pages;
|
||||||
use App\Filament\Resources\System\ExamResource\RelationManagers;
|
use App\Filament\Resources\System\ExamResource\RelationManagers;
|
||||||
use App\Models\Exam;
|
use App\Models\Exam;
|
||||||
|
use App\Repositories\ExamRepository;
|
||||||
use App\Repositories\UserRepository;
|
use App\Repositories\UserRepository;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Resources\Form;
|
use Filament\Resources\Form;
|
||||||
@@ -131,9 +132,13 @@ class ExamResource extends Resource
|
|||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
Tables\Actions\EditAction::make(),
|
Tables\Actions\EditAction::make(),
|
||||||
|
Tables\Actions\DeleteAction::make()->using(function ($record) {
|
||||||
|
$rep = new ExamRepository();
|
||||||
|
$rep->delete($record->id);
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
->bulkActions([
|
->bulkActions([
|
||||||
Tables\Actions\DeleteBulkAction::make(),
|
// Tables\Actions\DeleteBulkAction::make(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class CreateExam extends CreateRecord
|
|||||||
public function create(bool $another = false): void
|
public function create(bool $another = false): void
|
||||||
{
|
{
|
||||||
$data = $this->form->getState();
|
$data = $this->form->getState();
|
||||||
// dd($data);
|
|
||||||
$examRep = new ExamRepository();
|
$examRep = new ExamRepository();
|
||||||
try {
|
try {
|
||||||
$this->record = $examRep->store($data);
|
$this->record = $examRep->store($data);
|
||||||
@@ -28,9 +27,10 @@ class CreateExam extends CreateRecord
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->redirect($this->getRedirectUrl());
|
$this->redirect($this->getResource()::getUrl('index'));
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
$this->notify('danger', $exception->getMessage());
|
$this->notify('danger', $exception->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Filament\OptionsTrait;
|
|||||||
use App\Filament\Resources\System\SettingResource;
|
use App\Filament\Resources\System\SettingResource;
|
||||||
use App\Models\HitAndRun;
|
use App\Models\HitAndRun;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms\ComponentContainer;
|
use Filament\Forms\ComponentContainer;
|
||||||
use Filament\Forms\Concerns\InteractsWithForms;
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
|
||||||
@@ -31,10 +32,13 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
|||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
static::authorizeResourceAccess();
|
static::authorizeResourceAccess();
|
||||||
|
$this->fillForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fillForm()
|
||||||
|
{
|
||||||
$settings = Setting::get();
|
$settings = Setting::get();
|
||||||
$this->form->fill($settings);
|
$this->form->fill($settings);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getFormSchema(): array
|
protected function getFormSchema(): array
|
||||||
@@ -73,12 +77,9 @@ class EditSetting extends Page implements Forms\Contracts\HasForms
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting::query()->upsert($data, ['name'], ['value']);
|
Setting::query()->upsert($data, ['name'], ['value']);
|
||||||
NexusDB::cache_del('nexus_settings_in_laravel');
|
clear_setting_cache();
|
||||||
NexusDB::cache_del('nexus_settings_in_nexus');
|
Filament::notify('success', __('filament::resources/pages/edit-record.messages.saved'), true);
|
||||||
|
|
||||||
$this->notify('success', __('filament::resources/pages/edit-record.messages.saved'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTabs(): array
|
private function getTabs(): array
|
||||||
|
|||||||
Reference in New Issue
Block a user