/**
  * @param Model      $model
  * @param Repository $repository
  *
  * @return mixed
  */
 public function apply(Model $model, Repository $repository)
 {
     return $model->withTrashed();
 }
Exemple #2
0
 /**
  * Apply soft-delete changes to the query.
  *
  * @param Model|Builder $query
  * @return mixed
  */
 protected function applySoftDeletesQuery($query)
 {
     if ($this->withTrashed === true) {
         return $query->withTrashed();
     } elseif ($this->onlyTrashed === true) {
         return $query->onlyTrashed();
     }
     return $query;
 }
Exemple #3
0
 /**
  * Reset and includes soft deletes for following queries.
  *
  * @return $this
  */
 public function startWithTrashed()
 {
     /**
      * Save to conditons.
      */
     $this->addCondition('withTrashed', 'withTrashed');
     $this->model = $this->model->withTrashed();
     return $this;
 }
 /**
  * Reset and includes soft deletes for following queries.
  *
  * @return $this
  */
 public function startWithTrashed()
 {
     $this->reset(new Action(__METHOD__, []));
     /**
      * Save to conditons.
      */
     $this->addCondition('withTrashed', 'withTrashed');
     $this->model = $this->model->withTrashed();
     return $this;
 }
 /**
  * Retrieve all data of repository deleted
  *
  * @param array $columns
  *
  * @return mixed
  */
 public function withTrashed($columns = ['*'])
 {
     $this->applyCriteria();
     $this->applyScope();
     if ($this->model instanceof Builder) {
         $results = $this->model->withTrashed()->get($columns);
     } else {
         $results = $this->model->withTrashed()->get($columns);
     }
     $this->resetModel();
     $this->resetScope();
     return $this->parserResult($results);
 }
Exemple #6
0
 /**
  * Restore a model
  *
  * @param int $id
  */
 public function restored($id)
 {
     $object = $this->model->withTrashed()->find($id);
     $object->restore();
 }
Exemple #7
0
 /**
  * Get single model by slug
  *
  * @param string slug
  * @return object object of model
  */
 public function byIdWithTrashed($id)
 {
     return $this->model->withTrashed()->find($id);
 }