如何重新排序Laravel Nova的导航,包括团体?

时间:2019-10-22 11:30:07

标签: laravel laravel-nova

如何按照客户的意愿更改订单的顺序?

1 个答案:

答案 0 :(得分:0)

  1. 您在代码库中的某个地方创建了Laravel\Nova\Tools\ResourceManager的副本。
  2. 您在"files"

    下的 composer.json 中添加了一个"autoload"
    "autoload": {
          "psr-4": {
              "App\\": "app/"
          },
          "classmap": [
              "database/seeds",
              "database/factories"
          ],
          "files": ["app/<your path>/ResourceManager.php"]
    },
    
  3. ResourceManager.php 中,您进行更改

    public function renderNavigation()
    {
        $request = request();
        $groups = Nova::groups($request);
    
        $newNavigation = collect([
            'Group1' => collect([
                Resource1::class,
                Resource2::class,
                Resource3::class,
            ]),
            'Group2' => collect([
                Resource4::class,
                Resource5::class,
            ]),    
        ]);
    
        return view('nova::resources.navigation', [
            'navigation' => $newNavigation,
            'groups' => $groups,
        ]);
    }