Exemplo n.º 1
0
 /**
  * @param Builder $model
  * @param IPaginateRepository $repository
  * @param array $filters
  *
  * @return Builder
  * @throws BadDataQueryException
  */
 public function apply(Builder $model, IPaginateRepository $repository, array $filters)
 {
     foreach ($this->inputService->decode('filters') as $filter) {
         $model = $this->applyFilter($filter, $model, $repository);
     }
     foreach ($filters as $filter) {
         $model = $this->addFilter($model, $filter);
     }
     return $model;
 }
Exemplo n.º 2
0
 /**
  * Get relation array
  *
  * @param Repository $repository
  * @param array $relations
  * @return array
  */
 private function getRelations(Repository $repository, array $relations = [])
 {
     // if we have relation array passed, ignore request input
     if (count($relations) === 0) {
         $relations = Input::get('with');
         if (!is_array($relations)) {
             $relations = $this->inputService->decode('with');
         }
     }
     $result = [];
     $repo_relations = $repository->relations();
     foreach ($relations as $key => $value) {
         if (in_array($key, $repo_relations)) {
             $result[] = $key;
         } elseif (in_array($value, $repo_relations)) {
             $result[] = $value;
         }
     }
     return $result;
 }