/** * Gets the saved model from the event and then transforms it to an array. * Then it indexes the saved model. * * @param IndexesWhenSaved $event */ public function handle(IndexesWhenSaved $event) { $model = $event->getModel(); $attributes = $model->getIndexableAttributes($model); $attributes = $model->transformAttributes($attributes); $this->laralastica->add($model->getSearchType(), $model->getSearchKey(), $attributes); }
/** * Gets the saved model from the event and then transforms it to an array. * Then it indexes the saved model. * * @param RemovesDocumentWhenDeleted $event */ public function handle(RemovesDocumentWhenDeleted $event) { $model = $event->getModel(); $this->laralastica->delete($model->getSearchType(), $model->getSearchKey()); }