some fix
This commit is contained in:
@ -84,42 +84,14 @@ class ModuleShopController extends AdminController
|
||||
|
||||
public function actionView(int $id): void
|
||||
{
|
||||
$module = ModuleShop::find($id);
|
||||
|
||||
$module = ModuleShop::find($id);
|
||||
if (!$module) {
|
||||
throw new Exception("The module not found");
|
||||
}
|
||||
$this->cgView->render("view.php", ['module' => $module]);
|
||||
}
|
||||
|
||||
public function actionUpdate(int $id): void
|
||||
{
|
||||
$model = ModuleShop::find($id);
|
||||
|
||||
if (!$model) {
|
||||
throw new Exception("The module not found");
|
||||
}
|
||||
|
||||
$this->cgView->render("form.php", ['model' => $model]);
|
||||
}
|
||||
|
||||
public function actionEdit(int $id): void
|
||||
{
|
||||
$module = ModuleShop::find($id);
|
||||
|
||||
if (!$module) {
|
||||
throw new Exception("The module not found");
|
||||
}
|
||||
$moduleForm = new CreateModuleShopForm();
|
||||
$moduleForm->load($_REQUEST);
|
||||
if ($moduleForm->validate()) {
|
||||
$module = $this->moduleShopService->update($moduleForm, $module);
|
||||
if ($module) {
|
||||
$this->redirect("/admin/module_shop/" . $module->id);
|
||||
}
|
||||
}
|
||||
$this->redirect("/admin/module_shop/update/" . $id);
|
||||
}
|
||||
|
||||
public function actionDelete(int $id): void
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ class ModuleShop extends Model
|
||||
|
||||
protected $table = "module_shop";
|
||||
|
||||
protected $fillable = ['name', 'slug', 'version', 'description', 'author', 'status', 'path_to_archive', 'dependence'];
|
||||
protected $fillable = ['name', 'slug', 'version', 'description', 'author', 'status', 'dependence'];
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
@ -33,7 +33,6 @@ class ModuleShop extends Model
|
||||
'author' => 'Автор',
|
||||
'status' => 'Статус',
|
||||
'slug' => 'Slug',
|
||||
'path_to_archive' => 'Путь к файлу модуля',
|
||||
'dependence' => 'Зависимости',
|
||||
];
|
||||
}
|
||||
|
@ -50,27 +50,4 @@ class ModuleShopService extends ModuleService
|
||||
return false;
|
||||
}
|
||||
|
||||
public function packModule($module): void
|
||||
{
|
||||
$tmpModuleDir = md5(time());
|
||||
$authorSlug = Slug::createSlug($module->author);
|
||||
$nameSlug = Slug::createSlug($module->name);
|
||||
$tmpModuleDirFull = RESOURCES_DIR . '/tmp/modules/' . $tmpModuleDir . '/';
|
||||
|
||||
$fileHelper = new Files();
|
||||
Debug::dd(APP_DIR . '/modules/' . $nameSlug);
|
||||
$fileHelper->copy_folder(APP_DIR . '/modules/' . $nameSlug, $tmpModuleDirFull . 'app/');
|
||||
// $fileHelper->copy_folder(KERNEL_APP_MODULES_DIR . '/' . $nameSlug, $tmpModuleDirFull . 'kernel/');
|
||||
|
||||
$fileHelper->pack(
|
||||
$tmpModuleDirFull,
|
||||
RESOURCES_DIR . '/module_shop/' .
|
||||
$authorSlug . '/' .
|
||||
$module->slug . '/' .
|
||||
$module->version . '/' .
|
||||
$nameSlug . '.itguild'
|
||||
);
|
||||
|
||||
$fileHelper->recursiveRemoveDir($tmpModuleDirFull);
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class ModuleShopDeleteActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/delete/";
|
||||
|
||||
public function fetch()
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-danger'>Удалить</a> ";
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class ModuleShopEditActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/update/";
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-success'>Редактировать</a> ";
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class ModuleShopPackActionColumn extends ActionColumn
|
||||
{
|
||||
protected string $prefix = "/pack/";
|
||||
|
||||
public function fetch()
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-info'>Заархивировать</a> ";
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\table\columns;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class ModuleShopViewActionColumn extends actionColumn
|
||||
{
|
||||
protected string $prefix = "/";
|
||||
|
||||
public function fetch(): string
|
||||
{
|
||||
$link = $this->baseUrl . $this->prefix . $this->id;
|
||||
return " <a href='$link' class='btn btn-primary'>Просмотр</a> ";
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
use app\modules\module_shop\models\ModuleShop;
|
||||
|
||||
$form = new \itguild\forms\ActiveForm();
|
||||
$form->beginForm(isset($model) ? "/admin/module_shop/edit/" . $model->id : "/admin/module_shop", enctype: 'multipart/form-data');
|
||||
$form->beginForm("/admin/module_shop", enctype: 'multipart/form-data');
|
||||
|
||||
|
||||
|
||||
|
@ -7,11 +7,9 @@
|
||||
use app\modules\module_shop\models\ModuleShop;
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\IGTabel\action_column\DeleteActionColumn;
|
||||
use kernel\IGTabel\action_column\ViewActionColumn;
|
||||
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(\app\modules\module_shop\models\ModuleShop::class, [
|
||||
'currentPage' => $page_number,
|
||||
@ -29,8 +27,7 @@ $table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/module_shop/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
$table->addAction(\app\modules\module_shop\table\columns\ModuleShopViewActionColumn::class);
|
||||
$table->addAction(\app\modules\module_shop\table\columns\ModuleShopEditActionColumn::class);
|
||||
$table->addAction(\app\modules\module_shop\table\columns\ModuleShopDeleteActionColumn::class);
|
||||
$table->addAction(ViewActionColumn::class);
|
||||
$table->addAction(DeleteActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
@ -18,7 +18,6 @@ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($module, [
|
||||
]));
|
||||
$table->beforePrint(function () use ($module) {
|
||||
$btn = PrimaryBtn::create("Список", "/admin/module_shop")->fetch();
|
||||
$btn .= SuccessBtn::create("Редактировать", "/admin/module_shop/update/" . $module->id)->fetch();
|
||||
$btn .= DangerBtn::create("Удалить", "/admin/module_shop/delete/" . $module->id)->fetch();
|
||||
return $btn;
|
||||
});
|
||||
|
Reference in New Issue
Block a user