/**
  * @param Builder $model
  * @param IPaginateRepository $repository
  * @param array $filters
  *
  * @return Builder
  * @throws FilterException
  */
 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;
 }
 /**
  * @param array $relations
  * @return array
  */
 private function getRelations(array $relations = [])
 {
     $with = is_array(Input::get('with')) ? Input::get('with') : $this->inputService->decode('with');
     if (count($relations) > 0) {
         $with = $relations;
     }
     $result = [];
     $relations = $this->repository->relations();
     foreach ($with as $key => $value) {
         if (in_array($key, $relations) || in_array($value, $relations)) {
             $result[$key] = $value;
         }
     }
     return $result;
 }