diff --git a/README.md b/README.md index efbdae2..6a90f89 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,38 @@ $panel ) ``` +### Using Menus + +Getting the assigned menu for a registered location can be done using the `Menu` model. Below we will call the menu assigned to the `primary` location: + +```php +use Datlechin\FilamentMenuBuilder\Models\Menu; + +$menu = Menu::location('primary'); +``` + +Menu items can be iterated from the `menuItems` relationship: + +```php +@foreach ($menu->menuItems as $item) + {{ $item->title }} +@endforeach +``` + +When a menu item is a parent, a collection of the child menu items will be available on the `children` property: + +```php +@foreach ($menu->menuItems as $item) + {{ $item->title }} + + @if ($item->children) + @foreach ($item->children as $child) + {{ $child->title }} + @endforeach + @endif +@endforeach +``` + ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.