Skip to content
kai edited this page Feb 13, 2020 · 1 revision

Basic Usage

The sortBy method sorts the menu items by the given key:

Menu::make('example', function(Builder $menu) {
    $menu->add('Blog', 'blog')->data('order', 3);
    $menu->add('Contact', 'contact')->data('order', 4);
    $menu->add('About', 'about')->data('order', 2);
    $menu->add('Home', '/')->data('order', 1);
})->sortBy('order');

The above example will sort your menu items by the order meta data in ascending order.

Descending Order

The sortByDesc method has the same signature as the sortBy method, but will sort the menu items in the opposite order.