From db8c4ec4f9b3c807680f3f6ccaaa8652bd0cf9a3 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 20 Aug 2024 05:03:21 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Add=20simple=20menu=20usage=20do?= =?UTF-8?q?cumentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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.