Skip to content

Commit

Permalink
Filter empty menu-items (#4016)
Browse files Browse the repository at this point in the history
* Filter empty sub-menu items

* Naming
  • Loading branch information
emptynick committed Mar 20, 2019
1 parent c4038dc commit 97d1b08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ private static function processItems($items)
// Filter items by permission
$items = $items->filter(function ($item) {
return !$item->children->isEmpty() || app('VoyagerAuth')->user()->can('browse', $item);
})->filter(function ($item) {
// Filter out empty menu-items
if ($item->href == '' && $item->children->count() == 0) {
return false;
}

return true;
});

return $items->values();
Expand Down

0 comments on commit 97d1b08

Please sign in to comment.