MicroFrameWork/kernel/modules/menu/views/index.php
2024-12-25 16:32:23 +03:00

47 lines
1.5 KiB
PHP

<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $menuItem
* @var int $page_number
*/
use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable;
use kernel\models\Menu;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [
'currentPage' => $page_number,
'perPage' => 8,
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/settings/menu",
]));
$table->columns([
'parent_id' => function ($data) {
if ($data == 0) return null;
return Menu::find($data)->label;
},
'icon_file' => function ($data) {
return $data ? "<img src='$data' width='150px'>" : "";
},
'status' => function ($data) {
return Menu::getStatus()[$data];
}
]);
$table->beforePrint(function () {
return IconBtnCreateWidget::create(['url' => '/admin/settings/menu/create'])->run();
});
$table->addAction(function($row) {
return IconBtnViewWidget::create(['url' => '/admin/settings/menu/view/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/settings/menu/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/settings/menu/delete/' . $row['id']])->run();
});
$table->create();
$table->render();