first
This commit is contained in:
parent
c3c377a4e2
commit
b7ac923261
34
app/modules/module_shop/ModuleShopModule.php
Normal file
34
app/modules/module_shop/ModuleShopModule.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop;
|
||||
|
||||
use kernel\Module;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
use kernel\services\MigrationService;
|
||||
|
||||
class ModuleShopModule extends Module
|
||||
{
|
||||
public MenuService $menuService;
|
||||
public MigrationService $migrationService;
|
||||
public function __construct()
|
||||
{
|
||||
$this->menuService = new MenuService();
|
||||
$this->migrationService = new MigrationService();
|
||||
}
|
||||
|
||||
public function init(): void
|
||||
{
|
||||
$this->migrationService->runAtPath("{APP}/modules/module_shop/migrations");
|
||||
|
||||
$this->menuService->createItem([
|
||||
"label" => "Магазин модулей",
|
||||
"url" => "/admin/module_shop",
|
||||
"slug" => "module_shop",
|
||||
]);
|
||||
}
|
||||
|
||||
public function deactivate(): void
|
||||
{
|
||||
$this->menuService->removeItemBySlug("module_shop");
|
||||
}
|
||||
}
|
25
app/modules/module_shop/controllers/ModuleShopController.php
Normal file
25
app/modules/module_shop/controllers/ModuleShopController.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\controllers;
|
||||
|
||||
use kernel\AdminController;
|
||||
use kernel\app_modules\tag\services\TagService;
|
||||
use kernel\services\ModuleService;
|
||||
|
||||
class ModuleShopController extends AdminController
|
||||
{
|
||||
protected ModuleService $moduleService;
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/module_shop/views/";
|
||||
$this->moduleService = new ModuleService();
|
||||
}
|
||||
|
||||
public function actionIndex($page_number): void
|
||||
{
|
||||
$this->cgView->render("index.php", ['page_number' => $page_number]);
|
||||
}
|
||||
|
||||
}
|
11
app/modules/module_shop/manifest.json
Normal file
11
app/modules/module_shop/manifest.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Магазин модулей",
|
||||
"version": "0.1",
|
||||
"author": "ITGuild",
|
||||
"slug": "module_shop",
|
||||
"description": "Магазин модулей для IGF",
|
||||
"app_module_path": "{APP}/modules/{slug}",
|
||||
"module_class": "app\\modules\\module_shop\\ModuleShopModule",
|
||||
"routs": "routs/ms.php",
|
||||
"dependence": "menu"
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
\kernel\App::$db->schema->create('module_shop', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string("name", 255)->nullable(false);
|
||||
$table->string("slug", 255)->nullable(false);
|
||||
$table->text("description")->nullable(false);
|
||||
$table->string("version", 255)->nullable(false);
|
||||
$table->string("author", 255)->nullable(false);
|
||||
$table->string("dependence", 255)->nullable(true);
|
||||
$table->text("path_to_archive")->nullable(false);
|
||||
$table->integer("status")->default(1);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
\kernel\App::$db->schema->dropIfExists('module_shop');
|
||||
}
|
||||
};
|
41
app/modules/module_shop/models/ModuleShop.php
Normal file
41
app/modules/module_shop/models/ModuleShop.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace app\modules\module_shop\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ModuleShop extends Model
|
||||
{
|
||||
const DISABLE_STATUS = 0;
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = "module_shop";
|
||||
|
||||
protected $fillable = ['name', 'slug', 'version', 'description', 'author', 'status', 'path_to_archive', 'dependence'];
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'Название',
|
||||
'version' => 'Версия',
|
||||
'description' => 'Описание',
|
||||
'author' => 'Автор',
|
||||
'status' => 'Статус',
|
||||
'slug' => 'Slug',
|
||||
'path_to_archive' => 'Путь к файлу модуля',
|
||||
'dependence' => 'Зависимости',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getStatus(): array
|
||||
{
|
||||
return [
|
||||
self::DISABLE_STATUS => "Не активный",
|
||||
self::ACTIVE_STATUS => "Активный",
|
||||
];
|
||||
}
|
||||
|
||||
}
|
21
app/modules/module_shop/routs/ms.php
Normal file
21
app/modules/module_shop/routs/ms.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\CgRouteCollector;
|
||||
|
||||
App::$collector->group(["prefix" => "admin"], function (CgRouteCollector $router) {
|
||||
App::$collector->group(["prefix" => "module_shop"], function (CgRouteCollector $router){
|
||||
App::$collector->get('/', [\app\modules\module_shop\controllers\ModuleShopController::class, 'actionIndex']);
|
||||
App::$collector->get('/page/{page_number}', [\app\modules\module_shop\controllers\ModuleShopController::class, 'actionIndex']);
|
||||
// App::$collector->get('/create', [\kernel\modules\menu\controllers\MenuController::class, 'actionCreate']);
|
||||
// App::$collector->post("/", [\kernel\modules\menu\controllers\MenuController::class, 'actionAdd']);
|
||||
// App::$collector->get('/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionView']);
|
||||
// App::$collector->any('/update/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionUpdate']);
|
||||
// App::$collector->any("/edit/{id}", [\kernel\modules\menu\controllers\MenuController::class, 'actionEdit']);
|
||||
// App::$collector->get('/delete/{id}', [\kernel\modules\menu\controllers\MenuController::class, 'actionDelete']);
|
||||
});
|
||||
});
|
||||
|
||||
App::$collector->group(["prefix" => "api"], function (CgRouteCollector $router){
|
||||
$router->rest("module_shop", [\app\modules\module_shop\controllers\ModuleShopController::class]);
|
||||
});
|
26
app/modules/module_shop/views/index.php
Normal file
26
app/modules/module_shop/views/index.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $menuItem
|
||||
* @var int $page_number
|
||||
*/
|
||||
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
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,
|
||||
'perPage' => 8,
|
||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||
'baseUrl' => "/admin/settings/menu",
|
||||
]));
|
||||
$table->beforePrint(function () {
|
||||
return PrimaryBtn::create("Создать", "/admin/module_shop/create")->fetch();
|
||||
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
||||
});
|
||||
$table->create();
|
||||
$table->render();
|
Loading…
x
Reference in New Issue
Block a user