Skip to content
Advertisement

Laravel Nova – Reorder left navigation menu items

In default the ordering of left menu items is in alphabetical order.

My client wants to order those menus manually. Any idea how to make it possible?

enter image description here

Go to answer

Advertisement

Answer

There are two ways to achieve this:

  1. By setting priority to Resource
  2. Ordering Resource models in NovaServiceProvider

1. Priority Method

  • Add priority as in the following code in Resource model:
      public static $priority = 2;
    
  • Then update NovaServiceProvider like this:
    public function boot()
    {
        Nova::sortResourcesBy(function ($resource) {
            return $resource::$priority ?? 9999;
        });
    }
    

2. Ordering Resource models in NovaServiceProvider

In NovaServiceProvider, order Resource models like this:

protected function resources()
{
    Nova::resources([
        User::class,
        Post::class,
    ]);
 }
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement