diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/TagModule.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/controllers/TagController.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/app/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/"; - $this->tagService = new TagService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $tagForm = new CreateTagForm(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()){ - $tag = $this->tagService->create($tagForm); - if ($tag){ - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $tag = Tag::find($id); - - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $this->cgView->render("view.php", ['tag' => $tag]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Tag::find($id); - if (!$model){ - throw new Exception(message: "The tag not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $tag = Tag::find($id); - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $tagForm = new CreateTagForm(); - $tagService = new TagService(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()) { - $tag = $tagService->update($tagForm, $tag); - if ($tag) { - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $post = Tag::find($id)->first(); - $post->delete(); - $this->redirect("/admin/tag/"); - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/migrations/2024_10_08_093710_create_tag_table.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/migrations/2024_10_08_093710_create_tag_table.php deleted file mode 100644 index 37c4be5..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/migrations/2024_10_08_093710_create_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -schema->create('tag', function (Blueprint $table) { - $table->increments('id'); - $table->string('label', 255)->nullable(false); - $table->string('entity', 255)->nullable(false); - $table->string('slug', 255)->unique(); - $table->integer('status')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - \kernel\App::$db->schema->dropIfExists('tag'); - } -}; diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/Tag.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/Tag.php deleted file mode 100644 index 49e1bb4..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/Tag.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Заголовок', - 'entity' => 'Сущность', - 'slug' => 'Slug', - 'status' => 'Статус', - ]; - } - - /** - * @return string[] - */ - public static function getStatus(): array - { - return [ - self::DISABLE_STATUS => "Не активный", - self::ACTIVE_STATUS => "Активный", - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/forms/CreateTagForm.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/forms/CreateTagForm.php deleted file mode 100644 index 82fd893..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/models/forms/CreateTagForm.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|min-str-len:5|max-str-len:30', - 'entity' => 'required|min-str-len:1|max-str-len:50', - 'slug' => '', - 'status' => '' - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/routs/tag.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/routs/tag.php deleted file mode 100644 index 6ec41fe..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/routs/tag.php +++ /dev/null @@ -1,18 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["prefix" => "tag"], function (CGRouteCollector $router){ - App::$collector->get('/', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tag\controllers\TagController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tag\controllers\TagController::class, 'actionAdd']); - App::$collector->get('/{id}', [\app\modules\tag\controllers\TagController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tag\controllers\TagController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tag\controllers\TagController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tag\controllers\TagController::class, 'actionDelete']); - }); -}); \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/services/TagService.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/services/TagService.php deleted file mode 100644 index 9407f0a..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/services/TagService.php +++ /dev/null @@ -1,42 +0,0 @@ -label = $form_model->getItem('label'); - $model->entity = $form_model->getItem('entity'); - $model->status = $form_model->getItem('status'); - $model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - if ($model->save()){ - return $model; - } - - return false; - } - - public function update(FormModel $form_model, Tag $tag): false|Tag - { - if ($tag->label !== $form_model->getItem('label')) { - $tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - } - $tag->label = $form_model->getItem('label'); - $tag->entity = $form_model->getItem('entity'); - $tag->status = $form_model->getItem('status'); - - if ($tag->save()){ - return $tag; - } - - return false; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/form.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/form.php deleted file mode 100644 index 3a37b96..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/form.php +++ /dev/null @@ -1,58 +0,0 @@ -beginForm(isset($model) ? "/admin/tag/edit/" . $model->id : "/admin/tag"); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [ - 'class' => "form-control", - 'placeholder' => 'Заголовок', - 'value' => $model->label ?? '' -]) - ->setLabel("Заголовок") - ->render(); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "entity", params: [ - 'class' => "form-control", - 'placeholder' => 'Сущность', - 'value' => $model->entity ?? '' -]) - ->setLabel("Сущность") - ->render(); - -$form->field(\itguild\forms\inputs\Select::class, 'status', [ - 'class' => "form-control", - 'value' => $model->status ?? '' -]) - ->setLabel("Статус") - ->setOptions(Tag::getStatus()) - ->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(); diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/index.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/index.php deleted file mode 100644 index 0d5503f..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/index.php +++ /dev/null @@ -1,39 +0,0 @@ - $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); - -$table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch(); - //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); -}); - -$table->columns([ - "status" => [ - "value" => function ($cell) { - return Tag::getStatus()[$cell]; - }] -]); - -$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/view.php b/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/view.php deleted file mode 100644 index b09034f..0000000 --- a/resources/tmp/ad/288812b9d3be03880a18cfc8baa6b9cc/kernel/views/view.php +++ /dev/null @@ -1,30 +0,0 @@ - ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); -$table->beforePrint(function () use ($tag) { - $btn = PrimaryBtn::create("Список", "/admin/tag")->fetch(); - $btn .= SuccessBtn::create("Редактировать", "/admin/tag/update/" . $tag->id)->fetch(); - $btn .= DangerBtn::create("Удалить", "/admin/tag/delete/" . $tag->id)->fetch(); - return $btn; -}); -$table->rows([ - 'status' => (function ($data) { - return \kernel\app_modules\tag\models\Tag::getStatus()[$data]; - }) -]); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/TagModule.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/controllers/TagController.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/app/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/"; - $this->tagService = new TagService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $tagForm = new CreateTagForm(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()){ - $tag = $this->tagService->create($tagForm); - if ($tag){ - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $tag = Tag::find($id); - - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $this->cgView->render("view.php", ['tag' => $tag]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Tag::find($id); - if (!$model){ - throw new Exception(message: "The tag not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $tag = Tag::find($id); - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $tagForm = new CreateTagForm(); - $tagService = new TagService(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()) { - $tag = $tagService->update($tagForm, $tag); - if ($tag) { - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $post = Tag::find($id)->first(); - $post->delete(); - $this->redirect("/admin/tag/"); - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/migrations/2024_10_08_093710_create_tag_table.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/migrations/2024_10_08_093710_create_tag_table.php deleted file mode 100644 index 37c4be5..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/migrations/2024_10_08_093710_create_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -schema->create('tag', function (Blueprint $table) { - $table->increments('id'); - $table->string('label', 255)->nullable(false); - $table->string('entity', 255)->nullable(false); - $table->string('slug', 255)->unique(); - $table->integer('status')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - \kernel\App::$db->schema->dropIfExists('tag'); - } -}; diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/Tag.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/Tag.php deleted file mode 100644 index 49e1bb4..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/Tag.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Заголовок', - 'entity' => 'Сущность', - 'slug' => 'Slug', - 'status' => 'Статус', - ]; - } - - /** - * @return string[] - */ - public static function getStatus(): array - { - return [ - self::DISABLE_STATUS => "Не активный", - self::ACTIVE_STATUS => "Активный", - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/forms/CreateTagForm.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/forms/CreateTagForm.php deleted file mode 100644 index 82fd893..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/models/forms/CreateTagForm.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|min-str-len:5|max-str-len:30', - 'entity' => 'required|min-str-len:1|max-str-len:50', - 'slug' => '', - 'status' => '' - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/routs/tag.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/routs/tag.php deleted file mode 100644 index 6ec41fe..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/routs/tag.php +++ /dev/null @@ -1,18 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["prefix" => "tag"], function (CGRouteCollector $router){ - App::$collector->get('/', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tag\controllers\TagController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tag\controllers\TagController::class, 'actionAdd']); - App::$collector->get('/{id}', [\app\modules\tag\controllers\TagController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tag\controllers\TagController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tag\controllers\TagController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tag\controllers\TagController::class, 'actionDelete']); - }); -}); \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/services/TagService.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/services/TagService.php deleted file mode 100644 index 9407f0a..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/services/TagService.php +++ /dev/null @@ -1,42 +0,0 @@ -label = $form_model->getItem('label'); - $model->entity = $form_model->getItem('entity'); - $model->status = $form_model->getItem('status'); - $model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - if ($model->save()){ - return $model; - } - - return false; - } - - public function update(FormModel $form_model, Tag $tag): false|Tag - { - if ($tag->label !== $form_model->getItem('label')) { - $tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - } - $tag->label = $form_model->getItem('label'); - $tag->entity = $form_model->getItem('entity'); - $tag->status = $form_model->getItem('status'); - - if ($tag->save()){ - return $tag; - } - - return false; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/form.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/form.php deleted file mode 100644 index 3a37b96..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/form.php +++ /dev/null @@ -1,58 +0,0 @@ -beginForm(isset($model) ? "/admin/tag/edit/" . $model->id : "/admin/tag"); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [ - 'class' => "form-control", - 'placeholder' => 'Заголовок', - 'value' => $model->label ?? '' -]) - ->setLabel("Заголовок") - ->render(); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "entity", params: [ - 'class' => "form-control", - 'placeholder' => 'Сущность', - 'value' => $model->entity ?? '' -]) - ->setLabel("Сущность") - ->render(); - -$form->field(\itguild\forms\inputs\Select::class, 'status', [ - 'class' => "form-control", - 'value' => $model->status ?? '' -]) - ->setLabel("Статус") - ->setOptions(Tag::getStatus()) - ->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(); diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/index.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/index.php deleted file mode 100644 index 0d5503f..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/index.php +++ /dev/null @@ -1,39 +0,0 @@ - $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); - -$table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch(); - //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); -}); - -$table->columns([ - "status" => [ - "value" => function ($cell) { - return Tag::getStatus()[$cell]; - }] -]); - -$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/view.php b/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/view.php deleted file mode 100644 index b09034f..0000000 --- a/resources/tmp/ad/6061f1739a4083115f9124a9eefbc9e4/kernel/views/view.php +++ /dev/null @@ -1,30 +0,0 @@ - ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); -$table->beforePrint(function () use ($tag) { - $btn = PrimaryBtn::create("Список", "/admin/tag")->fetch(); - $btn .= SuccessBtn::create("Редактировать", "/admin/tag/update/" . $tag->id)->fetch(); - $btn .= DangerBtn::create("Удалить", "/admin/tag/delete/" . $tag->id)->fetch(); - return $btn; -}); -$table->rows([ - 'status' => (function ($data) { - return \kernel\app_modules\tag\models\Tag::getStatus()[$data]; - }) -]); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/TagModule.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/controllers/TagController.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/app/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/"; - $this->tagService = new TagService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $tagForm = new CreateTagForm(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()){ - $tag = $this->tagService->create($tagForm); - if ($tag){ - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $tag = Tag::find($id); - - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $this->cgView->render("view.php", ['tag' => $tag]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Tag::find($id); - if (!$model){ - throw new Exception(message: "The tag not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $tag = Tag::find($id); - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $tagForm = new CreateTagForm(); - $tagService = new TagService(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()) { - $tag = $tagService->update($tagForm, $tag); - if ($tag) { - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $post = Tag::find($id)->first(); - $post->delete(); - $this->redirect("/admin/tag/"); - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/migrations/2024_10_08_093710_create_tag_table.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/migrations/2024_10_08_093710_create_tag_table.php deleted file mode 100644 index 37c4be5..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/migrations/2024_10_08_093710_create_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -schema->create('tag', function (Blueprint $table) { - $table->increments('id'); - $table->string('label', 255)->nullable(false); - $table->string('entity', 255)->nullable(false); - $table->string('slug', 255)->unique(); - $table->integer('status')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - \kernel\App::$db->schema->dropIfExists('tag'); - } -}; diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/Tag.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/Tag.php deleted file mode 100644 index 49e1bb4..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/Tag.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Заголовок', - 'entity' => 'Сущность', - 'slug' => 'Slug', - 'status' => 'Статус', - ]; - } - - /** - * @return string[] - */ - public static function getStatus(): array - { - return [ - self::DISABLE_STATUS => "Не активный", - self::ACTIVE_STATUS => "Активный", - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/forms/CreateTagForm.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/forms/CreateTagForm.php deleted file mode 100644 index 82fd893..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/models/forms/CreateTagForm.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|min-str-len:5|max-str-len:30', - 'entity' => 'required|min-str-len:1|max-str-len:50', - 'slug' => '', - 'status' => '' - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/routs/tag.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/routs/tag.php deleted file mode 100644 index 6ec41fe..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/routs/tag.php +++ /dev/null @@ -1,18 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["prefix" => "tag"], function (CGRouteCollector $router){ - App::$collector->get('/', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tag\controllers\TagController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tag\controllers\TagController::class, 'actionAdd']); - App::$collector->get('/{id}', [\app\modules\tag\controllers\TagController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tag\controllers\TagController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tag\controllers\TagController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tag\controllers\TagController::class, 'actionDelete']); - }); -}); \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/services/TagService.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/services/TagService.php deleted file mode 100644 index 9407f0a..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/services/TagService.php +++ /dev/null @@ -1,42 +0,0 @@ -label = $form_model->getItem('label'); - $model->entity = $form_model->getItem('entity'); - $model->status = $form_model->getItem('status'); - $model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - if ($model->save()){ - return $model; - } - - return false; - } - - public function update(FormModel $form_model, Tag $tag): false|Tag - { - if ($tag->label !== $form_model->getItem('label')) { - $tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - } - $tag->label = $form_model->getItem('label'); - $tag->entity = $form_model->getItem('entity'); - $tag->status = $form_model->getItem('status'); - - if ($tag->save()){ - return $tag; - } - - return false; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/form.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/form.php deleted file mode 100644 index 3a37b96..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/form.php +++ /dev/null @@ -1,58 +0,0 @@ -beginForm(isset($model) ? "/admin/tag/edit/" . $model->id : "/admin/tag"); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [ - 'class' => "form-control", - 'placeholder' => 'Заголовок', - 'value' => $model->label ?? '' -]) - ->setLabel("Заголовок") - ->render(); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "entity", params: [ - 'class' => "form-control", - 'placeholder' => 'Сущность', - 'value' => $model->entity ?? '' -]) - ->setLabel("Сущность") - ->render(); - -$form->field(\itguild\forms\inputs\Select::class, 'status', [ - 'class' => "form-control", - 'value' => $model->status ?? '' -]) - ->setLabel("Статус") - ->setOptions(Tag::getStatus()) - ->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(); diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/index.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/index.php deleted file mode 100644 index 0d5503f..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/index.php +++ /dev/null @@ -1,39 +0,0 @@ - $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); - -$table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch(); - //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); -}); - -$table->columns([ - "status" => [ - "value" => function ($cell) { - return Tag::getStatus()[$cell]; - }] -]); - -$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/view.php b/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/view.php deleted file mode 100644 index b09034f..0000000 --- a/resources/tmp/ad/7289057c248ba8f15a95ff2a8ffdb261/kernel/views/view.php +++ /dev/null @@ -1,30 +0,0 @@ - ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); -$table->beforePrint(function () use ($tag) { - $btn = PrimaryBtn::create("Список", "/admin/tag")->fetch(); - $btn .= SuccessBtn::create("Редактировать", "/admin/tag/update/" . $tag->id)->fetch(); - $btn .= DangerBtn::create("Удалить", "/admin/tag/delete/" . $tag->id)->fetch(); - return $btn; -}); -$table->rows([ - 'status' => (function ($data) { - return \kernel\app_modules\tag\models\Tag::getStatus()[$data]; - }) -]); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/TagModule.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/controllers/TagController.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/app/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/"; - $this->tagService = new TagService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $tagForm = new CreateTagForm(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()){ - $tag = $this->tagService->create($tagForm); - if ($tag){ - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $tag = Tag::find($id); - - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $this->cgView->render("view.php", ['tag' => $tag]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Tag::find($id); - if (!$model){ - throw new Exception(message: "The tag not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $tag = Tag::find($id); - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $tagForm = new CreateTagForm(); - $tagService = new TagService(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()) { - $tag = $tagService->update($tagForm, $tag); - if ($tag) { - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $post = Tag::find($id)->first(); - $post->delete(); - $this->redirect("/admin/tag/"); - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/migrations/2024_10_08_093710_create_tag_table.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/migrations/2024_10_08_093710_create_tag_table.php deleted file mode 100644 index 37c4be5..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/migrations/2024_10_08_093710_create_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -schema->create('tag', function (Blueprint $table) { - $table->increments('id'); - $table->string('label', 255)->nullable(false); - $table->string('entity', 255)->nullable(false); - $table->string('slug', 255)->unique(); - $table->integer('status')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - \kernel\App::$db->schema->dropIfExists('tag'); - } -}; diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/Tag.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/Tag.php deleted file mode 100644 index 49e1bb4..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/Tag.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Заголовок', - 'entity' => 'Сущность', - 'slug' => 'Slug', - 'status' => 'Статус', - ]; - } - - /** - * @return string[] - */ - public static function getStatus(): array - { - return [ - self::DISABLE_STATUS => "Не активный", - self::ACTIVE_STATUS => "Активный", - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/forms/CreateTagForm.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/forms/CreateTagForm.php deleted file mode 100644 index 82fd893..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/models/forms/CreateTagForm.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|min-str-len:5|max-str-len:30', - 'entity' => 'required|min-str-len:1|max-str-len:50', - 'slug' => '', - 'status' => '' - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/routs/tag.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/routs/tag.php deleted file mode 100644 index 6ec41fe..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/routs/tag.php +++ /dev/null @@ -1,18 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["prefix" => "tag"], function (CGRouteCollector $router){ - App::$collector->get('/', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tag\controllers\TagController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tag\controllers\TagController::class, 'actionAdd']); - App::$collector->get('/{id}', [\app\modules\tag\controllers\TagController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tag\controllers\TagController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tag\controllers\TagController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tag\controllers\TagController::class, 'actionDelete']); - }); -}); \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/services/TagService.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/services/TagService.php deleted file mode 100644 index 9407f0a..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/services/TagService.php +++ /dev/null @@ -1,42 +0,0 @@ -label = $form_model->getItem('label'); - $model->entity = $form_model->getItem('entity'); - $model->status = $form_model->getItem('status'); - $model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - if ($model->save()){ - return $model; - } - - return false; - } - - public function update(FormModel $form_model, Tag $tag): false|Tag - { - if ($tag->label !== $form_model->getItem('label')) { - $tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - } - $tag->label = $form_model->getItem('label'); - $tag->entity = $form_model->getItem('entity'); - $tag->status = $form_model->getItem('status'); - - if ($tag->save()){ - return $tag; - } - - return false; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/form.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/form.php deleted file mode 100644 index 3a37b96..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/form.php +++ /dev/null @@ -1,58 +0,0 @@ -beginForm(isset($model) ? "/admin/tag/edit/" . $model->id : "/admin/tag"); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [ - 'class' => "form-control", - 'placeholder' => 'Заголовок', - 'value' => $model->label ?? '' -]) - ->setLabel("Заголовок") - ->render(); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "entity", params: [ - 'class' => "form-control", - 'placeholder' => 'Сущность', - 'value' => $model->entity ?? '' -]) - ->setLabel("Сущность") - ->render(); - -$form->field(\itguild\forms\inputs\Select::class, 'status', [ - 'class' => "form-control", - 'value' => $model->status ?? '' -]) - ->setLabel("Статус") - ->setOptions(Tag::getStatus()) - ->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(); diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/index.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/index.php deleted file mode 100644 index 0d5503f..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/index.php +++ /dev/null @@ -1,39 +0,0 @@ - $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); - -$table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch(); - //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); -}); - -$table->columns([ - "status" => [ - "value" => function ($cell) { - return Tag::getStatus()[$cell]; - }] -]); - -$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/view.php b/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/view.php deleted file mode 100644 index b09034f..0000000 --- a/resources/tmp/ad/cb177f1a6276ef6231a7e09311a283d0/kernel/views/view.php +++ /dev/null @@ -1,30 +0,0 @@ - ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); -$table->beforePrint(function () use ($tag) { - $btn = PrimaryBtn::create("Список", "/admin/tag")->fetch(); - $btn .= SuccessBtn::create("Редактировать", "/admin/tag/update/" . $tag->id)->fetch(); - $btn .= DangerBtn::create("Удалить", "/admin/tag/delete/" . $tag->id)->fetch(); - return $btn; -}); -$table->rows([ - 'status' => (function ($data) { - return \kernel\app_modules\tag\models\Tag::getStatus()[$data]; - }) -]); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/TagModule.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/TagModule.php deleted file mode 100644 index b2f0ffd..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/TagModule.php +++ /dev/null @@ -1,38 +0,0 @@ -menuService = new MenuService(); - $this->migrationService = new MigrationService(); - } - - /** - * @throws \Exception - */ - public function init(): void - { - $this->migrationService->runAtPath("{KERNEL_APP_MODULES}/tag/migrations"); - - $this->menuService->createItem([ - "label" => "Тэги", - "url" => "/admin/tag", - "slug" => "tag", - ]); - } - - public function deactivate(): void - { - $this->menuService->removeItemBySlug("tag"); - } -} \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/controllers/TagController.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/controllers/TagController.php deleted file mode 100644 index 4598872..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/app/controllers/TagController.php +++ /dev/null @@ -1,8 +0,0 @@ -cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/"; - $this->tagService = new TagService(); - } - - public function actionCreate(): void - { - $this->cgView->render("form.php"); - } - - #[NoReturn] public function actionAdd(): void - { - $tagForm = new CreateTagForm(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()){ - $tag = $this->tagService->create($tagForm); - if ($tag){ - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/create"); - } - - public function actionIndex($page_number = 1): void - { - $this->cgView->render("index.php", ['page_number' => $page_number]); - } - - /** - * @throws Exception - */ - public function actionView($id): void - { - $tag = Tag::find($id); - - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $this->cgView->render("view.php", ['tag' => $tag]); - } - - /** - * @throws Exception - */ - public function actionUpdate($id): void - { - $model = Tag::find($id); - if (!$model){ - throw new Exception(message: "The tag not found"); - } - - $this->cgView->render("form.php", ['model' => $model]); - } - - /** - * @throws Exception - */ - public function actionEdit($id): void - { - $tag = Tag::find($id); - if (!$tag){ - throw new Exception(message: "The tag not found"); - } - $tagForm = new CreateTagForm(); - $tagService = new TagService(); - $tagForm->load($_REQUEST); - if ($tagForm->validate()) { - $tag = $tagService->update($tagForm, $tag); - if ($tag) { - $this->redirect("/admin/tag/" . $tag->id); - } - } - $this->redirect("/admin/tag/update/" . $id); - } - - #[NoReturn] public function actionDelete($id): void - { - $post = Tag::find($id)->first(); - $post->delete(); - $this->redirect("/admin/tag/"); - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/migrations/2024_10_08_093710_create_tag_table.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/migrations/2024_10_08_093710_create_tag_table.php deleted file mode 100644 index 37c4be5..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/migrations/2024_10_08_093710_create_tag_table.php +++ /dev/null @@ -1,31 +0,0 @@ -schema->create('tag', function (Blueprint $table) { - $table->increments('id'); - $table->string('label', 255)->nullable(false); - $table->string('entity', 255)->nullable(false); - $table->string('slug', 255)->unique(); - $table->integer('status')->default(1); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - \kernel\App::$db->schema->dropIfExists('tag'); - } -}; diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/Tag.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/Tag.php deleted file mode 100644 index 49e1bb4..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/Tag.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Заголовок', - 'entity' => 'Сущность', - 'slug' => 'Slug', - 'status' => 'Статус', - ]; - } - - /** - * @return string[] - */ - public static function getStatus(): array - { - return [ - self::DISABLE_STATUS => "Не активный", - self::ACTIVE_STATUS => "Активный", - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/forms/CreateTagForm.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/forms/CreateTagForm.php deleted file mode 100644 index 82fd893..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/models/forms/CreateTagForm.php +++ /dev/null @@ -1,20 +0,0 @@ - 'required|min-str-len:5|max-str-len:30', - 'entity' => 'required|min-str-len:1|max-str-len:50', - 'slug' => '', - 'status' => '' - ]; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/routs/tag.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/routs/tag.php deleted file mode 100644 index 6ec41fe..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/routs/tag.php +++ /dev/null @@ -1,18 +0,0 @@ -group(["prefix" => "admin"], function (CgRouteCollector $router) { - App::$collector->group(["prefix" => "tag"], function (CGRouteCollector $router){ - App::$collector->get('/', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/page/{page_number}', [\app\modules\tag\controllers\TagController::class, 'actionIndex']); - App::$collector->get('/create', [\app\modules\tag\controllers\TagController::class, 'actionCreate']); - App::$collector->post("/", [\app\modules\tag\controllers\TagController::class, 'actionAdd']); - App::$collector->get('/{id}', [\app\modules\tag\controllers\TagController::class, 'actionView']); - App::$collector->any('/update/{id}', [\app\modules\tag\controllers\TagController::class, 'actionUpdate']); - App::$collector->any("/edit/{id}", [\app\modules\tag\controllers\TagController::class, 'actionEdit']); - App::$collector->get('/delete/{id}', [\app\modules\tag\controllers\TagController::class, 'actionDelete']); - }); -}); \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/services/TagService.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/services/TagService.php deleted file mode 100644 index 9407f0a..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/services/TagService.php +++ /dev/null @@ -1,42 +0,0 @@ -label = $form_model->getItem('label'); - $model->entity = $form_model->getItem('entity'); - $model->status = $form_model->getItem('status'); - $model->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - if ($model->save()){ - return $model; - } - - return false; - } - - public function update(FormModel $form_model, Tag $tag): false|Tag - { - if ($tag->label !== $form_model->getItem('label')) { - $tag->slug = Slug::createSlug($form_model->getItem('label'), Tag::class); - } - $tag->label = $form_model->getItem('label'); - $tag->entity = $form_model->getItem('entity'); - $tag->status = $form_model->getItem('status'); - - if ($tag->save()){ - return $tag; - } - - return false; - } - -} \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/form.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/form.php deleted file mode 100644 index 3a37b96..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/form.php +++ /dev/null @@ -1,58 +0,0 @@ -beginForm(isset($model) ? "/admin/tag/edit/" . $model->id : "/admin/tag"); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "label", params: [ - 'class' => "form-control", - 'placeholder' => 'Заголовок', - 'value' => $model->label ?? '' -]) - ->setLabel("Заголовок") - ->render(); - -$form->field(class: \itguild\forms\inputs\TextInput::class, name: "entity", params: [ - 'class' => "form-control", - 'placeholder' => 'Сущность', - 'value' => $model->entity ?? '' -]) - ->setLabel("Сущность") - ->render(); - -$form->field(\itguild\forms\inputs\Select::class, 'status', [ - 'class' => "form-control", - 'value' => $model->status ?? '' -]) - ->setLabel("Статус") - ->setOptions(Tag::getStatus()) - ->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(); diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/index.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/index.php deleted file mode 100644 index 0d5503f..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/index.php +++ /dev/null @@ -1,39 +0,0 @@ - $page_number, - 'perPage' => 8, - 'params' => ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); - -$table->beforePrint(function () { - return PrimaryBtn::create("Создать", "/admin/tag/create")->fetch(); - //return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); -}); - -$table->columns([ - "status" => [ - "value" => function ($cell) { - return Tag::getStatus()[$cell]; - }] -]); - -$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\DeleteActionColumn::class); -$table->addAction(\kernel\IGTabel\action_column\EditActionColumn::class); -$table->create(); -$table->render(); \ No newline at end of file diff --git a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/view.php b/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/view.php deleted file mode 100644 index b09034f..0000000 --- a/resources/tmp/ad/fb7687573df162d45c5044239738988c/kernel/views/view.php +++ /dev/null @@ -1,30 +0,0 @@ - ["class" => "table table-bordered", "border" => "2"], - 'baseUrl' => "/admin/tag", -])); -$table->beforePrint(function () use ($tag) { - $btn = PrimaryBtn::create("Список", "/admin/tag")->fetch(); - $btn .= SuccessBtn::create("Редактировать", "/admin/tag/update/" . $tag->id)->fetch(); - $btn .= DangerBtn::create("Удалить", "/admin/tag/delete/" . $tag->id)->fetch(); - return $btn; -}); -$table->rows([ - 'status' => (function ($data) { - return \kernel\app_modules\tag\models\Tag::getStatus()[$data]; - }) -]); -$table->create(); -$table->render(); \ No newline at end of file