> For the complete documentation index, see [llms.txt](https://pratikdai404.gitbook.io/adminetic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pratikdai404.gitbook.io/adminetic/services/mymenu.md).

# MyMenu

Manage your navigation menu

#### **Manage your navigation menu**

MyMenu class contains myMenu method that returns array of menus. By default we have following menus

```
<?php

namespace App\Services;

use Pratiksh\Adminetic\Services\Helper\SidebarHelper;
use Pratiksh\Adminetic\Contracts\SidebarInterface;

class MyMenu extends SidebarHelper implements SidebarInterface
{
    public function myMenu(): array
    {
        return [
            [
                'type' => 'breaker',
                'name' => 'General',
                'description' => 'Administration Control',
            ],
            [
                'type' => 'link',
                'name' => 'Dashboard',
                'icon' => 'fa fa-home',
                'link' => route('dashboard'),
                'is_active' => request()->routeIs('home') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
            ],
            [
                'type' => 'menu',
                'name' => 'User Management',
                'icon' => 'fa fa-users',
                'is_active' => request()->routeIs('user*') ? 'active' : '',
                'pill' => [
                    'class' => 'badge badge-info badge-air-info',
                    'value' => \App\Models\User::count(),
                ],
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \App\Models\User::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \App\Models\User::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('user', \App\Models\User::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Role',
                'icon' => 'fa fa-user-tie',
                'is_active' => request()->routeIs('role*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Role::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Role::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('role', \Pratiksh\Adminetic\Models\Admin\Role::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Permission',
                'icon' => 'fa fa-check',
                'is_active' => request()->routeIs('permission*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Permission::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Permission::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('permission', \Pratiksh\Adminetic\Models\Admin\Permission::class),
            ],
            [
                'type' => 'link',
                'name' => 'Setting',
                'icon' => 'fa fa-cog',
                'link' => adminRedirectRoute('setting'),
                'is_active' => request()->routeIs('home') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Setting::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Setting::class),
                    ],
                ],
            ],
            [
                'type' => 'menu',
                'name' => 'Preference',
                'icon' => 'fa fa-wrench',
                'is_active' => request()->routeIs('preference*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Preference::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Preference::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('preference', \Pratiksh\Adminetic\Models\Admin\Preference::class),
            ],
            [
                'type' => 'link',
                'name' => 'Activities',
                'icon' => 'fa fa-book',
                'is_active' => request()->routeIs('activity*') ? 'active' : '',
                'link' => adminRedirectRoute('activity'),
                'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
            ],
            [
                'type' => 'breaker',
                'name' => 'DEV TOOLS',
                'description' => 'Development Environment',
            ],
            [
                'type' => 'menu',
                'name' => 'Builder',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => env('APP_ENV') == 'local'
                    ],
                ],
                'children' => [
                    [
                        'type' => 'submenu',
                        'name' => 'Form Builder 1',
                        'link' => 'http://admin.pixelstrap.com/cuba/theme/form-builder-1.html',
                    ],
                    [
                        'type' => 'submenu',
                        'name' => 'Form Builder 2',
                        'link' => 'http://admin.pixelstrap.com/cuba/theme/form-builder-2.html',
                    ],
                    [
                        'type' => 'submenu',
                        'name' => 'Page Builder',
                        'link' => 'http://admin.pixelstrap.com/cuba/theme/pagebuild.html',
                    ],
                    [
                        'type' => 'submenu',
                        'name' => 'Buttom Builder',
                        'link' => 'http://admin.pixelstrap.com/cuba/theme/button-builder.html',
                    ],
                ]
            ],
            [
                'type' => 'menu',
                'name' => 'Documentation',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => env('APP_ENV') == 'local'
                    ],
                ],
                'children' => [
                    [
                        'type' => 'submenu',
                        'name' => 'Frontend Docs',
                        'link' => 'https://docs.pixelstrap.com/cuba/all_in_one/document/index.html',
                    ],
                    [
                        'type' => 'submenu',
                        'name' => 'Adminetic Docs',
                        'link' => 'https://pratikdai404.gitbook.io/adminetic/',
                    ],
                ]
            ],
            [
                'type' => 'link',
                'name' => 'Github',
                'icon' => 'fa fa-github',
                'link' => 'https://github.com/pratiksh404/admineticl',
            ],
        ];
    }
}

```

* Type: Type/Characteristic of \<emu
* Name: Header name of menu
* Icon: Icon of Menu
* is\_active: (bool) is menu active condition
* link: Redirect Route
* conditions: Condition to acces that route
* pill: Pill value and style
* children: children of menu header

### Explanations

### Type

There are three types of menu

<table data-header-hidden><thead><tr><th>Type</th><th>Characteristics</th></tr></thead><tbody><tr><td>Type</td><td>Characteristics</td></tr><tr><td>breaker</td><td><p>Defines a menu group</p><p>Consists</p><ul><li>name : eg=General</li><li>description: eg=Administrative Control </li></ul><p>  <img src="https://3590348543-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MbCZnEbkx6hMOJRn5tS%2F-MbV8n9OYB5cypScfuMu%2F-MbVFoWTgGoojPR4iYRt%2Fimage.png?alt=media&amp;token=17220494-7372-406b-9f6e-9e3b2fe5eaeb" alt="" data-size="original"></p></td></tr><tr><td>link</td><td><p>Single Menu Link</p><p>Consists</p><ul><li>name : Name of menu eg=Dashboard</li><li>icon: Icon of menu eg=fa fa-home</li><li>link: Route eg: route('dashboard')</li><li><p>pill: Small badge info takes class and value of badge</p><pre><code>'pill' => [
                    'class' => 'badge badge-info badge-air-info',
                    'value' => "Single Menu",
                ],
</code></pre></li><li><p>conditions: Take array of conditions that dictates visibility of the menu. array consists of <strong>type</strong> and <strong>condition</strong>. type can be <strong><code>or</code></strong> or <strong><code>and.</code></strong></p><pre><code>'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
</code></pre></li><li>is_active: bool value that states if the current menu route is active or not </li><li><p>eg:</p><pre><code>request()->routeIs('home') ? 'active' : '',
</code></pre></li></ul></td></tr><tr><td>menu</td><td><p>General Menu Containing Childrens</p><p></p><p>Consists</p><ul><li>name : Name of menu eg=User Management</li><li>icon: Icon of menu eg=fa fa-user</li><li>link: Route eg: adminRedirectRoute('user')</li><li><p>pill: Small badge info takes class and value of badge</p><pre><code>'pill' => [
                    'class' => 'badge badge-info badge-air-info',
                    'value' => \App\Models\User::count(),
                ],
</code></pre></li><li><p>conditions: Take array of conditions that dictates visibility of the menu. array consists of <strong>type</strong> and <strong>condition</strong>. type can be <strong><code>or</code></strong> or <strong><code>and.</code></strong></p><pre><code>'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
</code></pre></li><li>is_active: bool value that states if the current menu route is active or not </li><li><p>eg:</p><pre><code>  'is_active' => request()->routeIs('user*') ? 'active' : '',
</code></pre><ul><li>children: submenu of main menu</li><li>For module menu adminetic providers function</li><li>called <strong><code>indexCreateChildren</code></strong></li></ul><pre><code> 'children' => $this->indexCreateChildren('user', \App\Models\User::class),
</code></pre><p>or you can inject your own children</p><pre><code>'children' => [
           [
                'type' => 'submenu',
                'name' => 'All Users',
                'is_active' => request()->routeIs('user.index') ? 'active' : '',
                'link' => adminRedirectRoute('user'),
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \App\Models\User::class),
                    ],
                ],
            ],
            [
                'type' => 'submenu',
                'name' => 'Create User',
                'is_active' => request()->routeIs('user.create') ? 'active' : '',
                'link' => adminCreateRoute('user'),
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', $),
                    ],
                ],
            ],
        ]
</code></pre></li></ul></td></tr><tr><td></td><td></td></tr></tbody></table>

Here is the example of adminetic administration menu

```
 return [
            [
                'type' => 'breaker',
                'name' => 'General',
                'description' => 'Administration Control',
            ],
            [
                'type' => 'link',
                'name' => 'Dashboard',
                'icon' => 'fa fa-home',
                'link' => route('home'),
                'is_active' => request()->routeIs('home') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
            ],
            [
                'type' => 'menu',
                'name' => 'User Management',
                'icon' => 'fa fa-users',
                'is_active' => request()->routeIs('user*') ? 'active' : '',
                'pill' => [
                    'class' => 'badge badge-info badge-air-info',
                    'value' => \App\Models\User::count(),
                ],
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \App\Models\User::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \App\Models\User::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('user', \App\Models\User::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Role',
                'icon' => 'fa fa-black-tie',
                'is_active' => request()->routeIs('role*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Role::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Role::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('role', \Pratiksh\Adminetic\Models\Admin\Role::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Permission',
                'icon' => 'fa fa-check',
                'is_active' => request()->routeIs('permission*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Permission::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Permission::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('permission', \Pratiksh\Adminetic\Models\Admin\Permission::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Setting',
                'icon' => 'fa fa-cog',
                'is_active' => request()->routeIs('setting*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Setting::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Setting::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('setting', \Pratiksh\Adminetic\Models\Admin\Setting::class),
            ],
            [
                'type' => 'menu',
                'name' => 'Preference',
                'icon' => 'fa fa-wrench',
                'is_active' => request()->routeIs('preference*') ? 'active' : '',
                'conditions' => [
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('view-any', \Pratiksh\Adminetic\Models\Admin\Preference::class),
                    ],
                    [
                        'type' => 'or',
                        'condition' => auth()->user()->can('create', \Pratiksh\Adminetic\Models\Admin\Preference::class),
                    ],
                ],
                'children' => $this->indexCreateChildren('preference', \Pratiksh\Adminetic\Models\Admin\Preference::class),
            ],
            [
                'type' => 'link',
                'name' => 'Activities',
                'icon' => 'fa fa-book',
                'is_active' => request()->routeIs('activity*') ? 'active' : '',
                'link' => adminRedirectRoute('activity'),
                'conditions' => [
                    [
                        'type' => 'and',
                        'condition' => auth()->user()->hasRole('admin'),
                    ],
                ],
            ],
        ];
```

&#x20;
