2024-08-30 16:14:31 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Database\Eloquent\Collection $menuItem
|
|
|
|
* @var int $page_number
|
|
|
|
*/
|
|
|
|
|
|
|
|
use app\tables\columns\menu\MenuDeleteActionColumn;
|
|
|
|
use app\tables\columns\menu\MenuEditActionColumn;
|
|
|
|
use app\tables\columns\menu\MenuViewActionColumn;
|
|
|
|
use Itguild\EloquentTable\EloquentDataProvider;
|
|
|
|
use Itguild\EloquentTable\ListEloquentTable;
|
|
|
|
use kernel\IGTabel\btn\PrimaryBtn;
|
|
|
|
use kernel\models\Menu;
|
|
|
|
|
|
|
|
$table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [
|
|
|
|
'currentPage' => $page_number,
|
2024-09-03 16:29:44 +03:00
|
|
|
'perPage' => 8,
|
2024-08-30 16:14:31 +03:00
|
|
|
'params' => ["class" => "table table-bordered", "border" => "2"],
|
|
|
|
'baseUrl' => "/admin/menu",
|
|
|
|
]));
|
|
|
|
$table->columns([
|
|
|
|
'parent_id' => (function ($data) {
|
|
|
|
if ($data == 0) return null;
|
|
|
|
return Menu::find($data)->label;
|
2024-09-06 11:47:11 +03:00
|
|
|
})
|
2024-08-30 16:14:31 +03:00
|
|
|
]);
|
|
|
|
$table->beforePrint(function () {
|
|
|
|
return PrimaryBtn::create("Создать", "/admin/menu/create")->fetch();
|
|
|
|
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
|
|
|
|
});
|
|
|
|
$table->addAction(MenuViewActionColumn::class);
|
|
|
|
$table->addAction(MenuEditActionColumn::class);
|
|
|
|
$table->addAction(MenuDeleteActionColumn::class);
|
|
|
|
$table->create();
|
|
|
|
$table->render();
|