问题描述
默认情况下,左侧菜单项的顺序为字母顺序.
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?
推荐答案
更干净的方法,并在最新的Nova 3.x上进行了测试.此外,自2.10+版本起,此功能已添加到Nova中.您需要做的就是在nova类上添加一个静态属性.例如,客户将是:
A cleaner way and tested on latest Nova 3.x. Also, this has been added to Nova since version 2.10+ All you need to do is add a static property on your nova classes. For example Clients will be:
/**
* The side nav menu order.
*
* @var int
*/
public static $priority = 2;
然后,您可以使用NovaServiceProvider告诉nova使用您的自定义排序.您可以将代码放在boot method
Then after that you can use the NovaServiceProvider to tell nova to use your custom ordering. You can place the code in the boot method
public function boot()
{
Nova::sortResourcesBy(function ($resource) {
return $resource::$priority ?? 9999;
});
}
**参考 Nova私有存储库
这篇关于Laravel Nova-重新排序左侧导航菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!