您调用srearchable()的字段必须位于资源中的搜索数组中。
我有一个名为Customer的模型,该模型具有HasMany与Notes]模型的关系
与Customer具有BelongsTo关系public function notes() { return $this->hasMany(Note::class); }
和Note
nova resource]中定义了相同的关系>public function customer() { return $this->belongsTo(Customer::class); }
然后我在Note
BelongsTo::make('Customer', 'customer', Customer::class)
直到这里,如果要在BelongsTo字段上调用
->searchable()
,它不会从搜索中返回任何东西,那么现在所有东西都可以正常工作了>>BelongsTo::make('Customer', 'customer', Customer::class)->searchable()
我该如何解决这个问题
我有一个名为Customer的模型,具有HasMany关联到Notes模型公共函数notes(){return $ this-> hasMany(Note :: class); }和Note与客户之间具有BelongsTo关系...
您调用srearchable()的字段必须位于资源中的搜索数组中。
因此,如果您的字段是BelogsTo,则必须将您所属资源的title
字段放入sreach数组中在我的情况下,标题字段为
public static $title = 'name';
所以我把它放在
public static $search = [ 'id', 'name', ];
一切都会按预期进行
您调用srearchable()的字段必须位于资源中的搜索数组中。