예제 #1
0
 public function testReindexOneNotInConfig()
 {
     $esi = new ElasticSearchIndexer([]);
     $entity = $this->makeEntityMock();
     $entity->shouldReceive('addToIndex')->once();
     $esi->reindexOne($entity);
 }
예제 #2
0
 public function detachAll(ElasticSearchIndexer $searchIndexer, $id)
 {
     $parent = $this->findParentEntity($id);
     $this->checkPermission(static::class . '@detachAll', ['model' => $parent]);
     $reindexItems = $searchIndexer->getAllItemsFromRelations($parent, [$this->relationName]);
     $this->getRelation($parent)->detach();
     // Reindex parent entity
     $searchIndexer->reindexOne($parent, []);
     // Reindex all detached entities
     $searchIndexer->reindexMany($reindexItems, []);
     return $this->getResponse()->noContent();
 }
예제 #3
0
 /**
  * Delete many entites.
  *
  * @param  Request  $request
  * @return ApiResponse
  */
 public function deleteMany(Request $request, ElasticSearchIndexer $searchIndexer)
 {
     $requestCollection = $request->json()->all();
     $modelsCollection = $this->findOrFailCollection($requestCollection);
     $this->checkPermission(static::class . '@deleteMany', ['model' => $modelsCollection]);
     $searchIndexer->deleteManyAndReindexRelated($modelsCollection);
     return $this->getResponse()->noContent();
 }
예제 #4
0
 /**
  * Delete many entites.
  *
  * @param string $id
  * @param  Request  $request
  * @return ApiResponse
  */
 public function deleteMany(Request $request, ElasticSearchIndexer $searchIndexer, $id)
 {
     $requestCollection = $request->json()->all();
     $model = $this->findParentEntity($id);
     $childModels = $this->findOrFailChildrenCollection($requestCollection, $model);
     $this->checkPermission(static::class . '@deleteMany', ['model' => $model, 'children' => $childModels]);
     $searchIndexer->deleteManyAndReindexRelated($childModels);
     return $this->getResponse()->noContent();
 }