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();