我正在使用带有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索引中的用户.任何想法如何进行?