filters->except(self::DECORATION_FILTERS); } /** * @return Collection */ public function getDecorationFilters(){ return $this->filters->only(self::DECORATION_FILTERS); } // /** // * @param null|string $json // * @return array // */ // public function deserializeFilters(?string $json): array { // return $json !== null ? collect(json_decode($json))->toArray() : []; // } /** * @param null|string $param * @return array */ public function deserializeFilters($param): array { if(gettype($param) == "array"){ $json = implode(',', $param); } else{ $json = $param; } return $json !== null ? collect(json_decode($json))->toArray() : []; } /** * @return Builder */ private function applyFiltersToQuery(): Builder { return (new ApplyFiltersToQuery())->execute($this->getRepository(), $this->getQueryFilters()->toArray()); } /** * @param array $filters * @return mixed */ public function handler(array $filters, array $params = []){ $this->filters = collect($filters); return $this->getResults($this->applyFiltersToQuery(), $params); } /** * @return Builder */ abstract function getRepository(): Builder; /** * @param Builder $query * @return mixed */ abstract function getResults(Builder $query, array $params = []); }