app module
This commit is contained in:
16
kernel/IGTabel/action_column/ViewActionColumn.php
Normal file
16
kernel/IGTabel/action_column/ViewActionColumn.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\IGTabel\action_column;
|
||||
|
||||
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||
|
||||
class ViewActionColumn 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> ";
|
||||
}
|
||||
}
|
21
kernel/app_modules/tag/controllers/TagController.php
Normal file
21
kernel/app_modules/tag/controllers/TagController.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\tag\controllers;
|
||||
|
||||
use kernel\AdminController;
|
||||
use kernel\modules\menu\service\MenuService;
|
||||
|
||||
class TagController extends AdminController
|
||||
{
|
||||
protected function init(): void
|
||||
{
|
||||
parent::init();
|
||||
$this->cgView->viewPath = KERNEL_APP_MODULES_DIR . "/tag/views/";;
|
||||
}
|
||||
|
||||
public function actionIndex($page_number = 1): void
|
||||
{
|
||||
$this->cgView->render("index.php", ['page_number' => $page_number]);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?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('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');
|
||||
}
|
||||
};
|
37
kernel/app_modules/tag/models/Tag.php
Normal file
37
kernel/app_modules/tag/models/Tag.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\app_modules\tag\models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
const DISABLE_STATUS = 0;
|
||||
const ACTIVE_STATUS = 1;
|
||||
|
||||
protected $table = 'tag';
|
||||
|
||||
protected $fillable = ['label', 'entity', 'slug', 'status'];
|
||||
|
||||
public static function labels(): array
|
||||
{
|
||||
return [
|
||||
'label' => 'Заголовок',
|
||||
'entity' => 'Сущность',
|
||||
'slug' => 'Slug',
|
||||
'status' => 'Статус',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getStatus(): array
|
||||
{
|
||||
return [
|
||||
self::DISABLE_STATUS => "Не активный",
|
||||
self::ACTIVE_STATUS => "Активный",
|
||||
];
|
||||
}
|
||||
|
||||
}
|
18
kernel/app_modules/tag/routs/tag.php
Normal file
18
kernel/app_modules/tag/routs/tag.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use kernel\App;
|
||||
use kernel\CgRouteCollector;
|
||||
use Phroute\Phroute\RouteCollector;
|
||||
|
||||
App::$collector->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}', [\kernel\modules\menu\controllers\MenuController::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']);
|
||||
});
|
||||
});
|
31
kernel/app_modules/tag/views/index.php
Normal file
31
kernel/app_modules/tag/views/index.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Collection $menuItem
|
||||
* @var int $page_number
|
||||
*/
|
||||
|
||||
use Itguild\EloquentTable\EloquentDataProvider;
|
||||
use Itguild\EloquentTable\ListEloquentTable;
|
||||
use kernel\app_modules\tag\models\Tag;
|
||||
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(Tag::class, [
|
||||
'currentPage' => $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->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class);
|
||||
//$table->addAction(MenuEditActionColumn::class);
|
||||
//$table->addAction(MenuDeleteActionColumn::class);
|
||||
$table->create();
|
||||
$table->render();
|
@ -6,6 +6,7 @@ use Illuminate\Database\Migrations\DatabaseMigrationRepository;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use kernel\App;
|
||||
use kernel\helpers\Debug;
|
||||
|
||||
class MigrationService
|
||||
{
|
||||
@ -21,6 +22,8 @@ class MigrationService
|
||||
*/
|
||||
public function runAtPath(string $path = ROOT_DIR . '/migrations'): array
|
||||
{
|
||||
$path = getConst($path);
|
||||
|
||||
try {
|
||||
$dmr = new DatabaseMigrationRepository(App::$db->capsule->getDatabaseManager(), 'migration');
|
||||
|
||||
|
Reference in New Issue
Block a user