class OpsServer extends Resource
{
/**
* The model the resource corresponds to.
*
* @var string
*/
public static $model = \App\OpsServer::class;
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';
$ title资源有什么用途,如何使用?
我认为它无能为力
当资源显示在搜索结果中时,结果将显示资源的“标题”。例如,User
资源可以使用name
属性作为其标题。然后,当资源显示在全局搜索结果中时,将显示该属性。
要自定义资源的“标题”属性,可以在资源类上定义title
属性:
/**
* The single value that should be used to represent the resource when being displayed.
*
* @var string
*/
public static $title = 'name';
或者,您可以覆盖资源的title
方法:
/**
* Get the value that should be displayed to represent the resource.
*
* @return string
*/
public function title()
{
return $this->name;
}