Skip to content

Commit

Permalink
fix menu() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
3x1io committed Jul 18, 2024
1 parent 7370aea commit 089a1b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions src/Resources/MenuResource/Relations/MenuItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,15 @@ public function form(Form $form): Form
$routeCollection = Route::getRoutes();
foreach ($routeCollection as $key => $route) {
if (isset($route->action['as'])) {
$routeList[$route->action['as']] = $route->uri;
$routeList[] = [
"name" =>$route->action['as'],
"url" => $route->uri
];
} else {
array_push($routeList, $route->uri);
$routeList[] = [
"name" => $route->uri,
"url" => $route->uri
];
}
}

Expand Down Expand Up @@ -99,7 +105,7 @@ public function form(Form $form): Form
->hidden(fn(Forms\Get $get) => $get('is_route') === false)
->required(fn(Forms\Get $get) => $get('is_route') === true)
->searchable()
->options($routeList),
->options(collect($routeList)->pluck('url', 'name')->toArray()),
Forms\Components\Toggle::make('has_badge')
->default(false)
->label(trans('filament-menus::messages.cols.item.has_badge'))
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function menu($key){
$menu = \TomatoPHP\FilamentMenus\Models\Menu::where('key', $key)->first();

if($menu){
return collect($menu->items);
return collect($menu->menuItems);

}
else {
Expand Down

0 comments on commit 089a1b3

Please sign in to comment.