You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel Nova:如何删除Label Resources并设置可展开分组默认菜单?

Hey there! Let's sort out your Laravel Nova menu customization goals—collapsible grouped menus and removing that "Resources" label. Here's a step-by-step, working solution tailored for your needs:

1. Create a Custom Menu Provider

First, we'll build a custom menu provider to define your collapsible grouped menus. Create a new file app/Providers/NovaMenuServiceProvider.php with the following code:

<?php

namespace App\Providers;

use Laravel\Nova\Nova;
use Laravel\Nova\Menu\Menu;
use Laravel\Nova\Menu\MenuItem;
use Laravel\Nova\Menu\MenuSection;
use Illuminate\Support\ServiceProvider;

class NovaMenuServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Nova::mainMenu(function ($request) {
            return Menu::make()
                // Collapsible Group 1: User Management
                ->group('用户管理', function ($menu) {
                    $menu->resource(\App\Nova\User::class);
                    $menu->resource(\App\Nova\Role::class);
                    $menu->resource(\App\Nova\Permission::class);
                })->collapsible()

                // Collapsible Group 2: Content Management
                ->group('内容管理', function ($menu) {
                    $menu->resource(\App\Nova\Post::class);
                    $menu->resource(\App\Nova\Category::class);
                    $menu->resource(\App\Nova\Comment::class);
                })->collapsible()

                // Add external links or extra items if needed
                ->item(MenuItem::externalLink('系统设置', '/nova/settings'));
        });
    }
}

You can adjust group names and included resources to match your business needs—just keep adding ->group()->collapsible() blocks for more sections.

2. Register the Custom Menu Provider

Open config/nova.php and update the menu configuration to point to your new provider:

'menu' => App\Providers\NovaMenuServiceProvider::class,
3. Remove the "Resources" Label

You have two reliable options here:

First, publish Nova's language files to your local project:

php artisan vendor:publish --tag=nova-lang

Then open resources/lang/vendor/nova/en.json (adjust the language folder if you're using non-English locales) and modify the "Resources" entry:

{
    // ... other language keys
    "Resources": "",
    // ...
}

Option 2: Hide via Custom CSS

If you prefer a style-based approach, create a resources/css/nova.css file with:

.nova-sidebar .sidebar-header {
    display: none;
}

Then add this CSS file to Nova's asset configuration in config/nova.php:

'assets' => [
    public_path('css/nova.css'),
],

Don't forget to compile your assets if using Laravel Mix:

npm run dev
4. Test the Changes

Clear your config cache and refresh the Nova dashboard to see the results:

php artisan config:clear

Now your Nova sidebar should show collapsible grouped menus, and the "Resources" label will be gone!

Quick Notes

  • Double-check that all your required resources are added to the menu groups to avoid missing items
  • For multi-language setups, update the corresponding language files for each locale
  • If the CSS method doesn't work, inspect the sidebar with your browser's dev tools to confirm the correct class names (Nova versions may have minor changes)

内容的提问来源于stack exchange,提问作者Moum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 07:56:07