From f7253bafe92b8739a670b6d69558513f351467bd Mon Sep 17 00:00:00 2001 From: Kavalar Date: Thu, 12 Dec 2024 12:41:45 +0300 Subject: [PATCH] index template --- .../Еtest/controllers/ЕtestController.php | 8 -- app/modules/Еtest/manifest.json | 11 -- app/modules/Еtest/routs/Еtest.php | 2 - app/modules/Еtest/ЕtestModule.php | 8 -- .../Еtest/controllers/ЕtestController.php | 104 ------------------ kernel/app_modules/Еtest/routs/Еtest.php | 20 ---- kernel/app_modules/Еtest/ЕtestModule.php | 31 ------ kernel/console/routs/cli.php | 1 + kernel/templates/views/index_template | 37 ++++++- 9 files changed, 32 insertions(+), 190 deletions(-) delete mode 100644 app/modules/Еtest/controllers/ЕtestController.php delete mode 100644 app/modules/Еtest/manifest.json delete mode 100644 app/modules/Еtest/routs/Еtest.php delete mode 100644 app/modules/Еtest/ЕtestModule.php delete mode 100644 kernel/app_modules/Еtest/controllers/ЕtestController.php delete mode 100644 kernel/app_modules/Еtest/routs/Еtest.php delete mode 100644 kernel/app_modules/Еtest/ЕtestModule.php diff --git a/app/modules/Еtest/controllers/ЕtestController.php b/app/modules/Еtest/controllers/ЕtestController.php deleted file mode 100644 index c52a0ab..0000000 --- a/app/modules/Еtest/controllers/ЕtestController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/Еtest/views/"; - $this->ЕtestService = new ЕtestService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $ЕtestForm = new CreateЕtestForm(); - $ЕtestForm->load($_REQUEST); - if ($ЕtestForm->validate()){ - $Еtest = $this->ЕtestService->create($ЕtestForm); - if ($Еtest){ - $this->redirect("/admin/Еtest/view/" . $Еtest->id); - } - } - $this->redirect("/admin/Еtest/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $Еtest = Еtest::find($id); - - if (!$Еtest){ - throw new Exception(message: "The Еtest not found"); - } - $this->cgView->render("view.php", ['Еtest' => $Еtest]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Еtest::find($id); - if (!$model){ - throw new Exception(message: "The Еtest not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $Еtest = Еtest::find($id); - if (!$Еtest){ - throw new Exception(message: "The Еtest not found"); - } - $ЕtestForm = new CreateЕtestForm(); - $ЕtestService = new ЕtestService(); - $ЕtestForm->load($_REQUEST); - if ($ЕtestForm->validate()) { - $Еtest = $ЕtestService->update($ЕtestForm, $Еtest); - if ($Еtest) { - $this->redirect("/admin/Еtest/view/" . $Еtest->id); - } - } - $this->redirect("/admin/Еtest/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $Еtest = Еtest::find($id)->first(); - $Еtest->delete(); - $this->redirect("/admin/Еtest/"); - } -} \ No newline at end of file diff --git a/kernel/app_modules/Еtest/routs/Еtest.php b/kernel/app_modules/Еtest/routs/Еtest.php deleted file mode 100644 index 94a11f4..0000000 --- a/kernel/app_modules/Еtest/routs/Еtest.php +++ /dev/null @@ -1,20 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["before" => "auth"], function (RouteCollector $router) { - App::$collector->group(["prefix" => "Еtest"], function (CGRouteCollector $router) { - App::$collector->get('/', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\Еtest\controllers\ЕtestController::class, 'actionAdd']); - App::$collector->get('/view/{id}', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\Еtest\controllers\ЕtestController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\Еtest\controllers\ЕtestController::class, 'actionDelete']); - }); - }); -}); \ No newline at end of file diff --git a/kernel/app_modules/Еtest/ЕtestModule.php b/kernel/app_modules/Еtest/ЕtestModule.php deleted file mode 100644 index c5a03a4..0000000 --- a/kernel/app_modules/Еtest/ЕtestModule.php +++ /dev/null @@ -1,31 +0,0 @@ -menuService = new MenuService(); - } - - public function init(): void - { - $this->menuService->createItem([ - "label" => "Тест", - "url" => "/admin/Еtest", - "slug" => "Еtest", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("Еtest"); - } -} \ No newline at end of file diff --git a/kernel/console/routs/cli.php b/kernel/console/routs/cli.php index 869ad7b..e95e2fe 100644 --- a/kernel/console/routs/cli.php +++ b/kernel/console/routs/cli.php @@ -31,6 +31,7 @@ App::$collector->group(["prefix" => "module"], callback: function (RouteCollecto App::$collector->console('pack', [\kernel\console\controllers\ModuleController::class, 'actionPackModule']); App::$collector->console('update', [\kernel\console\controllers\ModuleController::class, 'actionUpdateModule']); App::$collector->console('construct', [\kernel\console\controllers\ModuleController::class, 'actionConstructModule']); + App::$collector->console('mk', [\kernel\console\controllers\ModuleController::class, 'actionMk']); }); App::$collector->group(["prefix" => "kernel"], callback: function (RouteCollector $router){ diff --git a/kernel/templates/views/index_template b/kernel/templates/views/index_template index c710ca6..076fa3c 100644 --- a/kernel/templates/views/index_template +++ b/kernel/templates/views/index_template @@ -13,12 +13,37 @@ use kernel\widgets\IconBtn\IconBtnDeleteWidget; use kernel\widgets\IconBtn\IconBtnEditWidget; use kernel\widgets\IconBtn\IconBtnViewWidget; -$table = new ListEloquentTable(new EloquentDataProvider({model}::class, [ - 'currentPage' => $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/{slug}" -])); +//Для использования таблицы с моделью, необходимо создать таблицу в базе данных +//$table = new ListEloquentTable(new EloquentDataProvider({model}::class, [ +// 'currentPage' => $page_number, +// 'perPage' => 8, +// 'params' => ["class" => "table table-bordered", "border" => "2"], +// 'baseUrl' => "/admin/{slug}" +//])); + + +$table = new \Itguild\Tables\ListJsonTable(json_encode( + [ + 'meta' => [ + 'total' => 0, + 'totalWithFilters' => 0, + 'columns' => [ + 'title', + 'slug', + 'status', + ], + 'perPage' => 5, + 'currentPage' => 1, + 'baseUrl' => '/admin/some', + 'params' => [ + 'class' => 'table table-bordered', + 'border' => 2 + ] + ], + 'filters' => [], + 'data' => [], + ] +)); $table->beforePrint(function () { return IconBtnCreateWidget::create(['url' => '/admin/{slug}/create'])->run();