I have an index in algolia using Documents and the users associated with theses 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');
}
}
In my case, i will update one day, the name of the Users, like this :
public function update(Request $request)
{
$user = Users::find(5);
$user->name = 'jean floriot';
$user->update();
}
But it never changes the User in the index of Algolia. Any ideas how to proceed ?
i'm using Laravel 5.5 with Scout
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire