public function index() { $query = Tarefa::query(); if ($this->request->getQuery('search_id')) { $query->andWhere('id = :id:')->bind(['id' => $this->request->getQuery('search_id')]); } else { $binds = []; if ($this->request->getQuery('search_nome')) { $query->andWhere('nome ILIKE :nome:'); $binds['nome'] = "%{$this->request->getQuery('search_nome')}%"; } if ($this->request->getQuery('search_descricao')) { $query->andWhere('descricao ILIKE :descricao:'); $binds['descricao'] = "%{$this->request->getQuery('search_descricao')}%"; } if ($this->request->getQuery('search_tipo')) { $query->andWhere('tipo = :tipo:'); $binds['tipo'] = $this->request->getQuery('search_tipo'); } if ($this->request->getQuery('search_status')) { $query->andWhere('status = :status:'); $binds['tipo'] = $this->request->getQuery('search_status'); } if ($this->request->getQuery('search_projeto')) { $query->andWhere('id_projeto = :projeto:'); $binds['projeto'] = $this->request->getQuery('search_projeto'); } if (count($binds)) { $query->bind($binds); } } if ($this->request->getQuery(DefaultParams::ORDER)) { $query->order($this->request->getQuery(DefaultParams::ORDER)); } return GetResponse::createResponse($this->request, $query->execute()->toArray()); }