Laravel 5.3 : 我可以将 table 的部分字段添加到 `algolia` 的索引中吗?
Laravel 5.3 : Can I add a part of the fields of an table to the index of `algolia`?
我可以将table的部分字段添加到algolia
的索引中吗?
例如:
有一个table articles
,它的文件是这样的:
id title content author status created_at updated_at deleted_at
我只想将 4 个字段 id title content author
添加到 algolia
、
的索引中
我在Laravel5.3
看了Scout
的文档,好像没有提到
您需要在您的模型上实施 toSearchableArray
方法。
public function toSearchableArray()
{
return [
'objectID' => $this->id,
'title' => $this->title,
'content' => $this->content,
'author' => $this->author,
]
}
我可以将table的部分字段添加到algolia
的索引中吗?
例如:
有一个table articles
,它的文件是这样的:
id title content author status created_at updated_at deleted_at
我只想将 4 个字段 id title content author
添加到 algolia
、
我在Laravel5.3
看了Scout
的文档,好像没有提到
您需要在您的模型上实施 toSearchableArray
方法。
public function toSearchableArray()
{
return [
'objectID' => $this->id,
'title' => $this->title,
'content' => $this->content,
'author' => $this->author,
]
}