(Laravel) 更改 Nova 资源名称? (仅在界面上)
(Laravel) Change Nova Resource name? (only on interface)
我正在尝试更改一个 Nova 资源的显示名称,而不更改它引用的数据库中的名称。仅用于查看/界面目的。
我检查了 App\Nova*myResource*.php 文件并找到了这个变量:
public static $title = 'newName';
但更改后仍然出现相同的旧名称。任何人都知道如何解决这个问题?也许我只需要用 artisan 键入一些命令。 (我已经尝试重启服务器)。
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.
例如如果您有 User
资源,您可以将 $title
设置为 email
,当您使用搜索时,他的 e-mail 将显示为标识他的属性:
要更改资源的标签,您可以覆盖资源 class.
中的 public static function label()
和 public static function singularLabel()
方法
之前:
之后:
/**
* 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';
}
我正在尝试更改一个 Nova 资源的显示名称,而不更改它引用的数据库中的名称。仅用于查看/界面目的。
我检查了 App\Nova*myResource*.php 文件并找到了这个变量:
public static $title = 'newName';
但更改后仍然出现相同的旧名称。任何人都知道如何解决这个问题?也许我只需要用 artisan 键入一些命令。 (我已经尝试重启服务器)。
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.
例如如果您有 User
资源,您可以将 $title
设置为 email
,当您使用搜索时,他的 e-mail 将显示为标识他的属性:
要更改资源的标签,您可以覆盖资源 class.
中的public static function label()
和 public static function singularLabel()
方法
之前:
之后:
/**
* 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';
}