Exemplo n.º 1
0
 public function delete()
 {
     $client = static::getEsClient();
     $esParams = array('index' => static::getEsIndex(), 'type' => static::INDEX_TYPE, 'id' => $this->search_id);
     try {
         $client->delete($esParams);
     } catch (Exception $e) {
         $message = json_decode($e->getMessage());
         if ($message->ok) {
             Log::warning("The annotation with id: " . $this->search_id . " was not found in ElasticSearch.  Deleting annotation from the DB...");
         } else {
             throw new Exception("Unable to delete annotation from ElasticSearch: " . $e->getMessage());
         }
     }
     DB::transaction(function () {
         $deletedMetas = NoteMeta::where('annotation_id', '=', $this->id)->delete();
         $deletedComments = AnnotationComment::where('annotation_id', '=', $this->id)->delete();
         $deletedPermissions = AnnotationPermission::where('annotation_id', '=', $this->id)->delete();
         $deletedRanges = AnnotationRange::where('annotation_id', '=', $this->id)->delete();
         $deletedTags = AnnotationTag::where('annotation_id', '=', $this->id)->delete();
         return parent::delete();
     });
 }