I’m trying to change the display name of one Nova resource, without change the name from de database that it references. Only for View / interface purposes.
I checked the AppNova*myResource*.php file and find this variable:
public static $title = 'newName';
But after change this the same old name still appears. Anyone knows how to resolve this? maybe I have just to type some comands with artisan. (I have alredy try to restart the server).
Advertisement
Answer
As Laravel nova docs states:
When a resource is shown within the search results, the results will display the “title” of the resource. For example, a User resource may use the name attribute as its title. Then, when the resource is shown within the global search results, that attribute will be displayed.
E.g. if you have User
resource, you can set $title
to email
and when you use a search, his e-mail will be displayed as an attribute identifying him:
To change resource’s label you can overwrite public static function label()
and public static function singularLabel()
methods in your resource’s class.
Before:
After:
/** * Get the displayable label of the resource. * * @return string */ public static function label() { return 'Customers'; } /** * Get the displayable singular label of the resource. * * @return string */ public static function singularLabel() { return 'Customer'; }