This filter is used to modify the dashboard side menu. It accepts one parameter which is the menu at its current state. Note that the end menu might be different from the expected result as other modules can overwrite the menu.

Using a higher priority make your script execute after every other. Here is how you'll register a custom menu.

You can define a priority by providing additional parameter to the function "addFilter".

Controlling Menu Visibility With Permissions

If your menus require some permissions to be seen by a user, you'll need to use the attribute "permissions" that accepts an array of "permissions" namespaces (identifier).

    'permissions'   =>   [ 'see.in.dark' ]

If more than one permission is provided, the user will have to have these permissions attached to his role.

Providing Sub Menus

The menu can only accept a hierarchy with one level down. This means a sub-menu cannot also have sub-menus. The shape of a sub menu is similar to the parent menu but doesn't include "icon" and "children", which aren't effective for sub menu.

    'childrens'  =>  [
        'submenu'  => [
            'label'   => 'Sub menu Label'

Every sub-menu same as the parent must be defined on a key-value pair. Make sure to define unique keys to avoid any possible conflict.

Inserting A Menu At A Specific Position

Most of the time, menus are injected at the end of the list. However, it's possible to insert a menu or a sub-menus after or before another menu. The key point here is to know the identifier of the menu. For example, if we would like to add a menu before inventory, we'll inspect the dashboard and get the identifier of the menu that displays the inventory's menu.

From there you should be able to spot the identifier of the menu.

In our example, the menu identifier we'll use is "inventory" and not "menu-inventory". We'll then use that identifier to insert a menu before "inventory".

The function "array_insert_before" can be used to insert an array before a specific key. The function "array_insert_after" can be used to insert an array after a specific key.