Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Nova display user-friendly resource name

Tags:

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...

like image 302
Slimez Avatar asked Sep 10 '18 16:09

Slimez


1 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.

like image 188
Marten van Urk Avatar answered Sep 19 '22 14:09

Marten van Urk