From 0f05bc23911c2a6c9134143aef2532758ddacd64 Mon Sep 17 00:00:00 2001 From: stasbilay02 Date: Mon, 23 Sep 2024 15:33:48 +0300 Subject: [PATCH] option CRUD --- .../columns/menu/MenuDeleteActionColumn.php | 32 +++--- .../columns/menu/MenuEditActionColumn.php | 32 +++--- .../columns/menu/MenuViewActionColumn.php | 32 +++--- .../columns/post/PostDeleteActionColumn.php | 30 +++--- .../columns/post/PostEditActionColumn.php | 30 +++--- .../columns/post/PostViewActionColumn.php | 30 +++--- .../columns/user/UserDeleteActionColumn.php | 30 +++--- .../columns/user/UserEditActionColumn.php | 30 +++--- .../columns/user/UserViewActionColumn.php | 30 +++--- .../table/columns/MenuDeleteActionColumn.php | 17 +++ .../table/columns/MenuEditActionColumn.php | 17 +++ .../table/columns/MenuViewActionColumn.php | 17 +++ kernel/modules/menu/views/index.php | 9 +- kernel/modules/option/OptionModule.php | 33 ++++++ .../option/controllers/OptionController.php | 102 ++++++++++++++++++ kernel/modules/option/manifest.json | 10 ++ kernel/modules/option/models/Option.php | 32 ++++++ .../option/models/forms/CreateOptionForm.php | 20 ++++ kernel/modules/option/routs/option.php | 17 +++ .../modules/option/service/OptionService.php | 49 +++++++++ .../columns/OptionDeleteActionColumn.php | 16 +++ .../table/columns/OptionEditActionColumn.php | 16 +++ .../table/columns/OptionViewActionColumn.php | 18 ++++ kernel/modules/option/views/form.php | 68 ++++++++++++ kernel/modules/option/views/index.php | 31 ++++++ kernel/modules/option/views/view.php | 23 ++++ .../table/columns/PostDeleteActionColumn.php | 16 +++ .../table/columns/PostEditActionColumn.php | 16 +++ .../table/columns/PostViewActionColumn.php | 16 +++ kernel/modules/post/views/index.php | 9 +- .../user/controllers/UserController.php | 1 + .../table/columns/UserDeleteActionColumn.php | 16 +++ .../table/columns/UserEditActionColumn.php | 16 +++ .../table/columns/UserViewActionColumn.php | 16 +++ kernel/modules/user/views/index.php | 7 +- 35 files changed, 737 insertions(+), 147 deletions(-) create mode 100644 kernel/modules/menu/table/columns/MenuDeleteActionColumn.php create mode 100644 kernel/modules/menu/table/columns/MenuEditActionColumn.php create mode 100644 kernel/modules/menu/table/columns/MenuViewActionColumn.php create mode 100644 kernel/modules/option/OptionModule.php create mode 100644 kernel/modules/option/controllers/OptionController.php create mode 100644 kernel/modules/option/manifest.json create mode 100644 kernel/modules/option/models/Option.php create mode 100644 kernel/modules/option/models/forms/CreateOptionForm.php create mode 100644 kernel/modules/option/routs/option.php create mode 100644 kernel/modules/option/service/OptionService.php create mode 100644 kernel/modules/option/table/columns/OptionDeleteActionColumn.php create mode 100644 kernel/modules/option/table/columns/OptionEditActionColumn.php create mode 100644 kernel/modules/option/table/columns/OptionViewActionColumn.php create mode 100644 kernel/modules/option/views/form.php create mode 100644 kernel/modules/option/views/index.php create mode 100644 kernel/modules/option/views/view.php create mode 100644 kernel/modules/post/table/columns/PostDeleteActionColumn.php create mode 100644 kernel/modules/post/table/columns/PostEditActionColumn.php create mode 100644 kernel/modules/post/table/columns/PostViewActionColumn.php create mode 100644 kernel/modules/user/table/columns/UserDeleteActionColumn.php create mode 100644 kernel/modules/user/table/columns/UserEditActionColumn.php create mode 100644 kernel/modules/user/table/columns/UserViewActionColumn.php diff --git a/app/tables/columns/menu/MenuDeleteActionColumn.php b/app/tables/columns/menu/MenuDeleteActionColumn.php index b767dae..8b70f7d 100644 --- a/app/tables/columns/menu/MenuDeleteActionColumn.php +++ b/app/tables/columns/menu/MenuDeleteActionColumn.php @@ -1,17 +1,17 @@ baseUrl . $this->prefix . $this->id; - return " Удалить "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\menu; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class MenuDeleteActionColumn extends ActionColumn +//{ +// +// protected string $prefix = "/delete/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Удалить "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/menu/MenuEditActionColumn.php b/app/tables/columns/menu/MenuEditActionColumn.php index 2ffec2e..33cded5 100644 --- a/app/tables/columns/menu/MenuEditActionColumn.php +++ b/app/tables/columns/menu/MenuEditActionColumn.php @@ -1,17 +1,17 @@ baseUrl . $this->prefix . $this->id; - return " Редактировать "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\menu; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class MenuEditActionColumn extends ActionColumn +//{ +// +// protected string $prefix = "/update/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Редактировать "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/menu/MenuViewActionColumn.php b/app/tables/columns/menu/MenuViewActionColumn.php index 802dac0..b6b8831 100644 --- a/app/tables/columns/menu/MenuViewActionColumn.php +++ b/app/tables/columns/menu/MenuViewActionColumn.php @@ -1,17 +1,17 @@ baseUrl . $this->prefix . $this->id; - return " Просмотр "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\menu; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class MenuViewActionColumn extends ActionColumn +//{ +// +// protected string $prefix = "/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Просмотр "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/post/PostDeleteActionColumn.php b/app/tables/columns/post/PostDeleteActionColumn.php index c79d8e7..3512308 100644 --- a/app/tables/columns/post/PostDeleteActionColumn.php +++ b/app/tables/columns/post/PostDeleteActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Удалить "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\post; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class PostDeleteActionColumn extends ActionColumn +//{ +// protected string $prefix = "/delete/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Удалить "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/post/PostEditActionColumn.php b/app/tables/columns/post/PostEditActionColumn.php index 32a7bf1..2d057ac 100644 --- a/app/tables/columns/post/PostEditActionColumn.php +++ b/app/tables/columns/post/PostEditActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Редактировать "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\post; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class PostEditActionColumn extends ActionColumn +//{ +// protected string $prefix = "/update/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Редактировать "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/post/PostViewActionColumn.php b/app/tables/columns/post/PostViewActionColumn.php index 37a3a10..565856c 100644 --- a/app/tables/columns/post/PostViewActionColumn.php +++ b/app/tables/columns/post/PostViewActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Просмотр "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\post; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class PostViewActionColumn extends actionColumn +//{ +// protected string $prefix = "/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Просмотр "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/user/UserDeleteActionColumn.php b/app/tables/columns/user/UserDeleteActionColumn.php index d4e32d2..5d3f411 100644 --- a/app/tables/columns/user/UserDeleteActionColumn.php +++ b/app/tables/columns/user/UserDeleteActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Удалить "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\user; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class UserDeleteActionColumn extends ActionColumn +//{ +// protected string $prefix = "/delete/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Удалить "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/user/UserEditActionColumn.php b/app/tables/columns/user/UserEditActionColumn.php index 76fbfbf..16dc87d 100644 --- a/app/tables/columns/user/UserEditActionColumn.php +++ b/app/tables/columns/user/UserEditActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Редактировать "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\user; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class UserEditActionColumn extends ActionColumn +//{ +// protected string $prefix = "/update/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Редактировать "; +// } +//} \ No newline at end of file diff --git a/app/tables/columns/user/UserViewActionColumn.php b/app/tables/columns/user/UserViewActionColumn.php index 74cb479..60f7bae 100644 --- a/app/tables/columns/user/UserViewActionColumn.php +++ b/app/tables/columns/user/UserViewActionColumn.php @@ -1,16 +1,16 @@ baseUrl . $this->prefix . $this->id; - return " Просмотр "; - } -} \ No newline at end of file +// +//namespace app\tables\columns\user; +// +//use Itguild\Tables\ActionColumn\ActionColumn; +// +//class UserViewActionColumn extends ActionColumn +//{ +// protected string $prefix = "/"; +// +// public function fetch(): string +// { +// $link = $this->baseUrl . $this->prefix . $this->id; +// return " Просмотр "; +// } +//} \ No newline at end of file diff --git a/kernel/modules/menu/table/columns/MenuDeleteActionColumn.php b/kernel/modules/menu/table/columns/MenuDeleteActionColumn.php new file mode 100644 index 0000000..c47f86a --- /dev/null +++ b/kernel/modules/menu/table/columns/MenuDeleteActionColumn.php @@ -0,0 +1,17 @@ +baseUrl . $this->prefix . $this->id; + return " Удалить "; + } +} \ No newline at end of file diff --git a/kernel/modules/menu/table/columns/MenuEditActionColumn.php b/kernel/modules/menu/table/columns/MenuEditActionColumn.php new file mode 100644 index 0000000..b7de57e --- /dev/null +++ b/kernel/modules/menu/table/columns/MenuEditActionColumn.php @@ -0,0 +1,17 @@ +baseUrl . $this->prefix . $this->id; + return " Редактировать "; + } +} \ No newline at end of file diff --git a/kernel/modules/menu/table/columns/MenuViewActionColumn.php b/kernel/modules/menu/table/columns/MenuViewActionColumn.php new file mode 100644 index 0000000..bb9f3ad --- /dev/null +++ b/kernel/modules/menu/table/columns/MenuViewActionColumn.php @@ -0,0 +1,17 @@ +baseUrl . $this->prefix . $this->id; + return " Просмотр "; + } +} \ No newline at end of file diff --git a/kernel/modules/menu/views/index.php b/kernel/modules/menu/views/index.php index c65a20f..eed36d2 100644 --- a/kernel/modules/menu/views/index.php +++ b/kernel/modules/menu/views/index.php @@ -4,13 +4,16 @@ * @var int $page_number */ -use app\tables\columns\menu\MenuDeleteActionColumn; -use app\tables\columns\menu\MenuEditActionColumn; -use app\tables\columns\menu\MenuViewActionColumn; +//use app\tables\columns\menu\MenuDeleteActionColumn; +//use app\tables\columns\menu\MenuEditActionColumn; +//use app\tables\columns\menu\MenuViewActionColumn; use Itguild\EloquentTable\EloquentDataProvider; use Itguild\EloquentTable\ListEloquentTable; use kernel\IGTabel\btn\PrimaryBtn; use kernel\models\Menu; +use kernel\modules\menu\table\columns\MenuDeleteActionColumn; +use kernel\modules\menu\table\columns\MenuEditActionColumn; +use kernel\modules\menu\table\columns\MenuViewActionColumn; $table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [ 'currentPage' => $page_number, diff --git a/kernel/modules/option/OptionModule.php b/kernel/modules/option/OptionModule.php new file mode 100644 index 0000000..0e2e6c2 --- /dev/null +++ b/kernel/modules/option/OptionModule.php @@ -0,0 +1,33 @@ +menuService = new MenuService(); + } + + /** + * @throws \Exception + */ + public function init(): void + { + $this->menuService->createItem([ + "label" => "Опции", + "url" => "/admin/option", + "slug" => "option" + ]); + } + + public function deactivate(): void + { + $this->menuService->removeItemBySlug("option"); + } +} \ No newline at end of file diff --git a/kernel/modules/option/controllers/OptionController.php b/kernel/modules/option/controllers/OptionController.php new file mode 100644 index 0000000..adff235 --- /dev/null +++ b/kernel/modules/option/controllers/OptionController.php @@ -0,0 +1,102 @@ +cgView->viewPath = KERNEL_MODULES_DIR . '/option/views/'; + $this->optionService = new OptionService(); + } + + public function actionCreate(): void + { + $this->cgView->render('form.php'); + } + + #[NoReturn] public function actionAdd(): void + { + $optionForm = new CreateOptionForm(); + $optionForm->load($_REQUEST); + if ($optionForm->validate()) { + $option = $this->optionService->create($optionForm); + if ($option) { + $this->redirect('/admin/option'); + } + } + $this->redirect('/admin/option/create'); + } + + public function actionIndex($page_number = 1): void + { + $this->cgView->render('index.php', ['page_number' => $page_number]); + } + + /** + * @throws \Exception + */ + public function actionView(int $id): void + { + $option = Option::find($id); + + if (!$option) { + throw new \Exception('Option not found'); + } + $this->cgView->render("view.php", ['option' => $option]); + } + + /** + * @throws \Exception + */ + public function actionUpdate(int $id): void + { + $model = Option::find($id); + + if (!$model) { + throw new \Exception('Option not found'); + } + + $this->cgView->render("form.php", ['model' => $model]); + } + + /** + * @throws \Exception + */ + public function actionEdit(int $id): void + { + Debug::prn($_REQUEST); + $option = Option::find($id); + if (!$option) { + throw new \Exception('Option not found'); + } + $optionForm = new CreateOptionForm(); + $optionService = new OptionService(); + $optionForm->load($_REQUEST); + if ($optionForm->validate()) { + $option = $optionService->update($optionForm, $option); + if ($option) { + $this->redirect('/admin/option' . $option->id); + } + } + $this->redirect('/admin/option/update' . $id); + } + + #[NoReturn] public function actionDelete(int $id): void + { + Option::find($id)->delete(); + $this->redirect('/admin/option'); + } + +} \ No newline at end of file diff --git a/kernel/modules/option/manifest.json b/kernel/modules/option/manifest.json new file mode 100644 index 0000000..7b236ee --- /dev/null +++ b/kernel/modules/option/manifest.json @@ -0,0 +1,10 @@ +{ + "name": "Option", + "version": "0.1", + "author": "ITGuild", + "slug": "option", + "description": "Option module", + "module_class": "kernel\\modules\\option\\OptionModule", + "module_class_file": "{KERNEL_MODULES}/option/OptionModule.php", + "routs": "routs/option.php" +} \ No newline at end of file diff --git a/kernel/modules/option/models/Option.php b/kernel/modules/option/models/Option.php new file mode 100644 index 0000000..26d335c --- /dev/null +++ b/kernel/modules/option/models/Option.php @@ -0,0 +1,32 @@ + 'Ключ', + 'value' => 'Значение', + 'label' => 'Название', + 'status' => 'Статус' + ]; + } + +} \ No newline at end of file diff --git a/kernel/modules/option/models/forms/CreateOptionForm.php b/kernel/modules/option/models/forms/CreateOptionForm.php new file mode 100644 index 0000000..921555e --- /dev/null +++ b/kernel/modules/option/models/forms/CreateOptionForm.php @@ -0,0 +1,20 @@ + '', + 'active_admin_theme' => '', + 'module_paths' => '', + 'active_modules' => '' + ]; + } + +} \ No newline at end of file diff --git a/kernel/modules/option/routs/option.php b/kernel/modules/option/routs/option.php new file mode 100644 index 0000000..d0c3f55 --- /dev/null +++ b/kernel/modules/option/routs/option.php @@ -0,0 +1,17 @@ +group(["prefix" => "admin"], function (RouteCollector $router){ + App::$collector->group(["prefix" => "option"], callback: function (RouteCollector $router){ + App::$collector->get('/', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']); + App::$collector->get('/page/{page_number}', [\kernel\modules\option\controllers\OptionController::class, 'actionIndex']); + App::$collector->get('/create', [\kernel\modules\option\controllers\OptionController::class, 'actionCreate']); + App::$collector->post("/", [\kernel\modules\option\controllers\OptionController::class, 'actionAdd']); + App::$collector->get('/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionView']); + App::$collector->any('/update/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionUpdate']); + App::$collector->any("/edit/{id}", [\kernel\modules\option\controllers\OptionController::class, 'actionEdit']); + App::$collector->get('/delete/{id}', [\kernel\modules\option\controllers\OptionController::class, 'actionDelete']); + }); +}); \ No newline at end of file diff --git a/kernel/modules/option/service/OptionService.php b/kernel/modules/option/service/OptionService.php new file mode 100644 index 0000000..2386440 --- /dev/null +++ b/kernel/modules/option/service/OptionService.php @@ -0,0 +1,49 @@ +key = $form_model->getItem('key'); + $model->value = $form_model->getItem('value'); + $model->label = $form_model->getItem('label'); + $model->status = $form_model->getItem('status'); + if ($model->save()) { + return $model; + } + + return false; + } + + public function update(FormModel $form_model, Option $option): false|Option + { + $option->key = $form_model->getItem('key'); + $option->value = $form_model->getItem('value'); + $option->label = $form_model->getItem('label'); + $option->status = $form_model->getItem('status'); + if ($option->save()) { + return $option; + } + + return false; + } + +// public function createOptionArr(): array +// { +// foreach (Option::all()->toArray() as $option) { +// $optionArr[$option['id']] = $option['key']; +// } +// if (!empty($optionArr)) { +// return $optionArr; +// } +// return []; +// } + +} \ No newline at end of file diff --git a/kernel/modules/option/table/columns/OptionDeleteActionColumn.php b/kernel/modules/option/table/columns/OptionDeleteActionColumn.php new file mode 100644 index 0000000..e7fda5b --- /dev/null +++ b/kernel/modules/option/table/columns/OptionDeleteActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Удалить "; + } +} \ No newline at end of file diff --git a/kernel/modules/option/table/columns/OptionEditActionColumn.php b/kernel/modules/option/table/columns/OptionEditActionColumn.php new file mode 100644 index 0000000..0ad8bfc --- /dev/null +++ b/kernel/modules/option/table/columns/OptionEditActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Редактировать "; + } +} \ No newline at end of file diff --git a/kernel/modules/option/table/columns/OptionViewActionColumn.php b/kernel/modules/option/table/columns/OptionViewActionColumn.php new file mode 100644 index 0000000..5c12242 --- /dev/null +++ b/kernel/modules/option/table/columns/OptionViewActionColumn.php @@ -0,0 +1,18 @@ +baseUrl . $this->prefix . $this->id; + return " Просмотр "; + } + +} \ No newline at end of file diff --git a/kernel/modules/option/views/form.php b/kernel/modules/option/views/form.php new file mode 100644 index 0000000..e7fde62 --- /dev/null +++ b/kernel/modules/option/views/form.php @@ -0,0 +1,68 @@ +beginForm(isset($model) ? "/admin/option/edit/" . $model->id : "/admin/option"); + +$form->field(\itguild\forms\inputs\TextInput::class, 'key', [ + 'class' => "form-control", + 'placeholder' => 'Ключ', + 'value' => $model->key ?? '' +]) + ->setLabel("Ключ") + ->render(); + +$form->field(\itguild\forms\inputs\TextInput::class, 'value', [ + 'class' => "form-control", + 'placeholder' => 'Значение', + 'value' => $model->value ?? '' +]) + ->setLabel("Значение") + ->render(); + +$form->field(\itguild\forms\inputs\TextInput::class, 'label', [ + 'class' => "form-control", + 'placeholder' => "Заголовок", + 'value' => $model->label ?? '' +]) + ->setLabel("Заголовок") + ->render(); + +$form->field(\itguild\forms\inputs\Select::class, 'status', [ + 'class' => "form-control", + 'value' => $model->status ?? '' +]) + ->setLabel("Статус") + ->setOptions(['1', '2']) + ->render(); + +?> +
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-submit", params: [ + 'class' => "btn btn-primary ", + 'value' => 'Отправить', + 'typeInput' => 'submit' + ]) + ->render(); + ?> +
+
+ field(\itguild\forms\inputs\Button::class, name: "btn-reset", params: [ + 'class' => "btn btn-warning", + 'value' => 'Сбросить', + 'typeInput' => 'reset' + ]) + ->render(); + ?> +
+
+endForm(); \ No newline at end of file diff --git a/kernel/modules/option/views/index.php b/kernel/modules/option/views/index.php new file mode 100644 index 0000000..8b02702 --- /dev/null +++ b/kernel/modules/option/views/index.php @@ -0,0 +1,31 @@ + $page_number, + 'per_page' => 5, + 'params' => ["class" => "table table-bordered", "border" => "2"], + 'baseUrl' => "/admin/option", +])); + +$table->beforePrint(function () { + return PrimaryBtn::create("Создать", "/admin/option/create")->fetch(); + //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); +}); + +$table->addAction(OptionViewActionColumn::class); +$table->addAction(OptionEditActionColumn::class); +$table->addAction(OptionDeleteActionColumn::class); +$table->create(); +$table->render(); \ No newline at end of file diff --git a/kernel/modules/option/views/view.php b/kernel/modules/option/views/view.php new file mode 100644 index 0000000..d8068c2 --- /dev/null +++ b/kernel/modules/option/views/view.php @@ -0,0 +1,23 @@ + ["class" => "table table-bordered", "border" => "2"], + 'baseUrl' => "/admin/user", +])); +$table->beforePrint(function () use ($option) { + $btn = PrimaryBtn::create("Список", "/admin/option")->fetch(); + $btn .= SuccessBtn::create("Редактировать", "/admin/option/update/" . $option->id)->fetch(); + $btn .= DangerBtn::create("Удалить", "/admin/option/delete/" . $option->id)->fetch(); + return $btn; +}); +$table->create(); +$table->render(); \ No newline at end of file diff --git a/kernel/modules/post/table/columns/PostDeleteActionColumn.php b/kernel/modules/post/table/columns/PostDeleteActionColumn.php new file mode 100644 index 0000000..c04ee6b --- /dev/null +++ b/kernel/modules/post/table/columns/PostDeleteActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Удалить "; + } +} \ No newline at end of file diff --git a/kernel/modules/post/table/columns/PostEditActionColumn.php b/kernel/modules/post/table/columns/PostEditActionColumn.php new file mode 100644 index 0000000..d2802bb --- /dev/null +++ b/kernel/modules/post/table/columns/PostEditActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Редактировать "; + } +} \ No newline at end of file diff --git a/kernel/modules/post/table/columns/PostViewActionColumn.php b/kernel/modules/post/table/columns/PostViewActionColumn.php new file mode 100644 index 0000000..ecdec5d --- /dev/null +++ b/kernel/modules/post/table/columns/PostViewActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Просмотр "; + } +} \ No newline at end of file diff --git a/kernel/modules/post/views/index.php b/kernel/modules/post/views/index.php index 8b29982..03e22a0 100644 --- a/kernel/modules/post/views/index.php +++ b/kernel/modules/post/views/index.php @@ -6,10 +6,13 @@ */ use kernel\modules\post\models\Post; +use kernel\modules\post\table\columns\PostDeleteActionColumn; +use kernel\modules\post\table\columns\PostEditActionColumn; +use kernel\modules\post\table\columns\PostViewActionColumn; use kernel\modules\user\models\User; -use app\tables\columns\post\PostDeleteActionColumn; -use app\tables\columns\post\PostEditActionColumn; -use app\tables\columns\post\PostViewActionColumn; +//use app\tables\columns\post\PostDeleteActionColumn; +//use app\tables\columns\post\PostEditActionColumn; +//use app\tables\columns\post\PostViewActionColumn; use Itguild\EloquentTable\EloquentDataProvider; use Itguild\EloquentTable\ListEloquentTable; use kernel\IGTabel\btn\PrimaryBtn; diff --git a/kernel/modules/user/controllers/UserController.php b/kernel/modules/user/controllers/UserController.php index 8ee1317..36c6700 100644 --- a/kernel/modules/user/controllers/UserController.php +++ b/kernel/modules/user/controllers/UserController.php @@ -67,6 +67,7 @@ class UserController extends AdminController * @throws RuntimeError * @throws SyntaxError * @throws LoaderError + * @throws Exception */ public function actionUpdate($id): void { diff --git a/kernel/modules/user/table/columns/UserDeleteActionColumn.php b/kernel/modules/user/table/columns/UserDeleteActionColumn.php new file mode 100644 index 0000000..641b26c --- /dev/null +++ b/kernel/modules/user/table/columns/UserDeleteActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Удалить "; + } +} \ No newline at end of file diff --git a/kernel/modules/user/table/columns/UserEditActionColumn.php b/kernel/modules/user/table/columns/UserEditActionColumn.php new file mode 100644 index 0000000..5dcdea3 --- /dev/null +++ b/kernel/modules/user/table/columns/UserEditActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Редактировать "; + } +} \ No newline at end of file diff --git a/kernel/modules/user/table/columns/UserViewActionColumn.php b/kernel/modules/user/table/columns/UserViewActionColumn.php new file mode 100644 index 0000000..aae3524 --- /dev/null +++ b/kernel/modules/user/table/columns/UserViewActionColumn.php @@ -0,0 +1,16 @@ +baseUrl . $this->prefix . $this->id; + return " Просмотр "; + } +} \ No newline at end of file diff --git a/kernel/modules/user/views/index.php b/kernel/modules/user/views/index.php index d551c89..2b51add 100644 --- a/kernel/modules/user/views/index.php +++ b/kernel/modules/user/views/index.php @@ -4,13 +4,14 @@ * @var int $page_number */ -use app\tables\columns\user\UserDeleteActionColumn; -use app\tables\columns\user\UserEditActionColumn; -use app\tables\columns\user\UserViewActionColumn; + use Itguild\EloquentTable\EloquentDataProvider; use Itguild\EloquentTable\ListEloquentTable; use kernel\IGTabel\btn\PrimaryBtn; use kernel\modules\user\models\User; +use kernel\modules\user\table\columns\UserDeleteActionColumn; +use kernel\modules\user\table\columns\UserEditActionColumn; +use kernel\modules\user\table\columns\UserViewActionColumn; $table = new ListEloquentTable(new EloquentDataProvider(User::class, [ 'currentPage' => $page_number,