MicroFrameWork/kernel/modules/menu/views/view.php

35 lines
1.1 KiB
PHP
Raw Normal View History

2024-09-03 16:29:44 +03:00
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $menu
*/
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\models\Menu;
2024-11-20 12:45:02 +03:00
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
2024-09-03 16:29:44 +03:00
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [
'params' => ["class" => "table table-bordered", "border" => "2"],
2024-09-06 11:47:11 +03:00
'baseUrl' => "/admin/settings/menu",
2024-09-03 16:29:44 +03:00
]));
2024-09-03 17:36:10 +03:00
2024-09-03 16:29:44 +03:00
$table->beforePrint(function () use ($menu) {
2024-11-20 12:45:02 +03:00
$btn = IconBtnListWidget::create(['url' => '/admin/settings/menu'])->run();
$btn .= IconBtnEditWidget::create(['url' => '/admin/settings/menu/update/' . $menu->id])->run();
$btn .= IconBtnDeleteWidget::create(['url' => '/admin/settings/menu/delete/' . $menu->id])->run();
2024-09-03 16:29:44 +03:00
return $btn;
});
$table->rows([
'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='300px'>" : "";
}
2024-09-03 16:29:44 +03:00
]);
$table->create();
$table->render();