This commit is contained in:
Билай Станислав 2024-09-06 11:47:11 +03:00
parent 9f132e7bc4
commit 4e031c7c8b
5 changed files with 5 additions and 47 deletions

View File

@ -23,20 +23,6 @@ $table->columns([
if ($data == 0) return null; if ($data == 0) return null;
return Menu::find($data)->label; return Menu::find($data)->label;
}), }),
'created_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
},
'updated_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
}
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/settings/menu/create")->fetch(); return PrimaryBtn::create("Создать", "/admin/settings/menu/create")->fetch();

View File

@ -14,7 +14,7 @@ use kernel\models\Menu;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/menu", 'baseUrl' => "/admin/settings/menu",
])); ]));
$table->beforePrint(function () use ($menu) { $table->beforePrint(function () use ($menu) {
@ -27,21 +27,7 @@ $table->rows([
'parent_id' => (function ($data) { 'parent_id' => (function ($data) {
if ($data == 0) return null; if ($data == 0) return null;
return Menu::find($data)->label; return Menu::find($data)->label;
}), })
'created_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
},
'updated_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
}
]); ]);
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -35,7 +35,7 @@ class MenuService
return false; return false;
} }
public static function getActiveStatus($url) public static function isActive($url): bool
{ {
if ($url === Request::getUrlPath()){ if ($url === Request::getUrlPath()){
return true; return true;

View File

@ -22,21 +22,7 @@ $table->columns([
'parent_id' => (function ($data) { 'parent_id' => (function ($data) {
if ($data == 0) return null; if ($data == 0) return null;
return Menu::find($data)->label; return Menu::find($data)->label;
}), })
'created_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
},
'updated_at' => function ($data) {
if (!$data){
return null;
}
return (new DateTimeImmutable($data))->format("d-m-Y");
}
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/menu/create")->fetch(); return PrimaryBtn::create("Создать", "/admin/menu/create")->fetch();

View File

@ -11,7 +11,7 @@
<a href="#item<?=$item->id?>" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><?= $item->label ?></a> <a href="#item<?=$item->id?>" data-toggle="collapse" aria-expanded="false" class="dropdown-toggle"><?= $item->label ?></a>
<ul class="collapse list-unstyled <?= \kernel\services\MenuService::hasActiveChild($item->id) ? "show" : "" ?>" id="item<?=$item->id?>"> <ul class="collapse list-unstyled <?= \kernel\services\MenuService::hasActiveChild($item->id) ? "show" : "" ?>" id="item<?=$item->id?>">
<?php foreach ($child as $subitem): ?> <?php foreach ($child as $subitem): ?>
<li class="<?= \kernel\services\MenuService::getActiveStatus($subitem->url) ? "active" : "" ?>"> <li class="<?= \kernel\services\MenuService::isActive($subitem->url) ? "active" : "" ?>">
<a href="<?= $subitem->url ?>"><?= $subitem->label ?></a> <a href="<?= $subitem->url ?>"><?= $subitem->label ?></a>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>