2024-09-03 16:29:44 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @var \Illuminate\Database\Eloquent\Collection $menuItem
|
|
|
|
* @var int $page_number
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Itguild\EloquentTable\EloquentDataProvider;
|
|
|
|
use Itguild\EloquentTable\ListEloquentTable;
|
|
|
|
use kernel\models\Menu;
|
2024-11-20 12:45:02 +03:00
|
|
|
use kernel\widgets\IconBtn\IconBtnCreateWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
|
|
|
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
2024-09-03 16:29:44 +03:00
|
|
|
|
|
|
|
$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;
|
|
|
|
}),
|
2024-11-20 13:41:31 +03:00
|
|
|
'icon_file' => function ($data) {
|
|
|
|
return $data ? "<img src='$data' width='150px'>" : "";
|
|
|
|
}
|
2024-09-03 16:29:44 +03:00
|
|
|
]);
|
|
|
|
$table->beforePrint(function () {
|
2024-11-20 12:45:02 +03:00
|
|
|
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();
|
2024-09-03 16:29:44 +03:00
|
|
|
});
|
|
|
|
$table->create();
|
|
|
|
$table->render();
|