public function index() { $query = Projeto::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 (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()); }