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

33 lines
1.0 KiB
PHP
Raw Normal View History

2024-09-03 16:29:44 +03:00
<?php
/**
* @var \Illuminate\Database\Eloquent\Collection $menu
*/
use app\models\User;
use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
use kernel\models\Menu;
$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) {
$btn = PrimaryBtn::create("Список", "/admin/settings/menu")->fetch();
$btn .= SuccessBtn::create("Редактировать", "/admin/settings/menu/update/" . $menu->id)->fetch();
$btn .= DangerBtn::create("Удалить", "/admin/settings/menu/delete/" . $menu->id)->fetch();
return $btn;
});
$table->rows([
'parent_id' => (function ($data) {
if ($data == 0) return null;
return Menu::find($data)->label;
2024-09-06 11:47:11 +03:00
})
2024-09-03 16:29:44 +03:00
]);
$table->create();
$table->render();