index template
This commit is contained in:
parent
1e566481f7
commit
f7253bafe9
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\ЕÑtest\controllers;
|
||||
|
||||
class ЕÑtestController extends \kernel\app_modules\ЕÑtest\controllers\ЕÑtestController
|
||||
{
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"name": "test",
|
||||
"version": "0.1",
|
||||
"author": "stas",
|
||||
"slug": "ЕÑtest",
|
||||
"description": "test module",
|
||||
"module_class": "app\\modules\\ЕÑtest\\ЕÑtestModule",
|
||||
"module_class_file": "{APP}/modules/ЕÑtest/ЕÑtestModule.php",
|
||||
"routs": "routs/ЕÑtest.php",
|
||||
"migration_path": "migrations"
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
<?php
|
||||
include KERNEL_APP_MODULES_DIR . "/ЕÑtest/routs/ЕÑtest.php";
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\ЕÑtest;
|
||||
|
||||
class ЕÑtestModule extends \kernel\app_modules\ЕÑtest\ЕÑtestModule
|
||||
{
|
||||
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\ЕÑtest\controllers;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
use kernel\AdminController;
|
||||
use kernel\app_modules\ЕÑtest\models\forms\CreateЕÑtestForm;
|
||||
use kernel\app_modules\ЕÑtest\models\ЕÑtest;
|
||||
use kernel\app_modules\ЕÑtest\services\ЕÑtestService;
|
||||
use kernel\EntityRelation;
|
||||
use kernel\Flash;
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\models\Option;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\Request;
|
||||
|
||||
class ЕÑtestController extends AdminController
|
||||
{
|
||||
private ЕÑtestService $ЕÑtestService;
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->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/");
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\CgRouteCollector;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->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']);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,31 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\ЕÑtest;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
|
||||
class ЕÑtestModule extends Module
|
||||
{
|
||||
|
||||
public MenuService $menuService;
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuService = new MenuService();
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->menuService->createItem([
|
||||
"label" => "ТеÑ<EFBFBD>Ñ‚",
|
||||
"url" => "/admin/ЕÑtest",
|
||||
"slug" => "ЕÑtest",
|
||||
]);
|
||||
}
|
||||
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("ЕÑtest");
|
||||
}
|
||||
}
|
@ -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){
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user