Vin*_*iot 2 laravel laravel-5 algolia laravel-scout
我正在使用带有Scout的Laravel 5.5.我在algolia中有一个索引,使用Documents和与这些文档相关的用户
class Documents extends Model
{
use Searchable;
public function toSearchableArray()
{
$data = $this->toArray();
// formatting relationship for algolia
$data['users'] = $this->types->toArray();
$data['document_type'] = $this->typeDocuments->name;
return $data;
}
protected $fillable = array('name', 'description', 'document_type');
public function types() {
return $this->belongsToMany('App\Users', 'document_rights', 'user_id', 'id');
}
public function typeDocuments() {
return $this->belongsTo('App\Document_type', 'document_type');
}
}
Run Code Online (Sandbox Code Playgroud)
就我而言,我会在一天内更新用户名,如下所示:
public function update(Request $request)
{
$user = Users::find(5);
$user->name = 'jean floriot';
$user->update();
}
Run Code Online (Sandbox Code Playgroud)
但它永远不会改变Algolia索引中的用户.任何想法如何进行?
我相信你可以使用searchable()方法.在$this->update()你得到类似的东西后:
App\Documents::where('user_id', '=', $this->id)->searchable();
Run Code Online (Sandbox Code Playgroud)
如果有效或者我错过了什么,请告诉我.
| 归档时间: |
|
| 查看次数: |
225 次 |
| 最近记录: |