Laravel Nova display user-friendly resource name

Viewed 16144

Let's say that I have a resource called "Resource_test". When I'm displaying that resource in Nova, that resource name (or "label") displays the name as-is which obviously isn't very user-friendly.

Is it possible to rename the "label" to "Resource Test" (without the underscore for example)?

It seems like they set the name in the file src\Nova.php on the static function resourceInformation but even though I change the name there, it doesn't seem to change the name on the site itself...

2 Answers

You can override the static label method within the resource class like this:

public static function label() {
    return 'Your own label';
}

You'll find your resource classes in the app/Nova directory. Do not confuse these classes with the identically-named models! Adding the label method to the model will not work.

You can take a look at the Nova\src\Resource.php class to view all the options.

Here this is how this can be done: Write this code in your nova resource Model File (app/Nova/ModelName.php):

For Index page:

    public static function label() {
        return 'Contact Us';
    }

For Create and Edit/Update page:

public static function singularLabel() {
    return 'Contact Us';
}
Related