flash, middleware
This commit is contained in:
@ -4,6 +4,7 @@ namespace kernel\modules\option\controllers;
|
||||
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\AdminController;
|
||||
use kernel\Flash;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\modules\option\models\forms\CreateOptionForm;
|
||||
use kernel\modules\option\models\Option;
|
||||
@ -33,9 +34,11 @@ class OptionController extends AdminController
|
||||
if ($optionForm->validate()) {
|
||||
$option = $this->optionService->create($optionForm);
|
||||
if ($option) {
|
||||
Flash::setMessage("success", "Опция успешно создана.");
|
||||
$this->redirect('/admin/option');
|
||||
}
|
||||
}
|
||||
Flash::setMessage("error", $optionForm->getErrorsStr());
|
||||
$this->redirect('/admin/option/create');
|
||||
}
|
||||
|
||||
@ -95,6 +98,7 @@ class OptionController extends AdminController
|
||||
#[NoReturn] public function actionDelete(int $id): void
|
||||
{
|
||||
Option::find($id)->delete();
|
||||
Flash::setMessage("success", "Опция успешно удалена.");
|
||||
$this->redirect('/admin/option');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user