Пример #1
0
 /**
  * Função responsavel por criar objeto de retorno de pesquisas
  * 
  * @param \wsGerProj\Http\Phalcon\Http\Request $request
  * @param array $data
  */
 public static function createResponse(\Phalcon\Http\Request $request, array $data)
 {
     $response = new GetResponse();
     $response->retorno = new GetResponseVO();
     $response->data = $data;
     $response->count = count($data);
     $response->retorno->count = $response->count;
     $response->request = $request;
     $response->setCurrentPage()->setPreviousPage()->setNextPage()->setResults();
     return $response->retorno;
 }
 public function index()
 {
     $query = Departamento::query();
     if ($this->request->getQuery('search_id')) {
         $query->andWhere('id = :id:')->bind(['id' => $this->request->getQuery('search_id')]);
     } else {
         if ($this->request->getQuery('search_descricao')) {
             $query->andWhere('descricao ILIKE :descricao:')->bind(['descricao' => "%{$this->request->getQuery('search_descricao')}%"]);
         }
     }
     if ($this->request->getQuery(DefaultParams::ORDER)) {
         $query->order($this->request->getQuery(DefaultParams::ORDER));
     }
     return GetResponse::createResponse($this->request, $query->execute()->toArray());
 }
 public function index()
 {
     $query = DepartamentosFuncionario::query()->columns(['id_funcionario', 'descricao as departamento'])->join('wsGerProj\\Models\\Departamento');
     $binds = [];
     if ($this->request->getQuery('search_id_funcionario')) {
         $query->andWhere('id_funcionario = :id_funcionario:');
         $binds['id_funcionario'] = $this->request->getQuery('search_id_funcionario');
     }
     if ($this->request->getQuery('search_id_departamento')) {
         $query->andWhere('id_departamento = :id_departamento:');
         $binds['id_departamento'] = $this->request->getQuery('search_id_departamento');
     }
     if (count($binds)) {
         $query->bind($binds);
     }
     return GetResponse::createResponse($this->request, $query->execute()->toArray());
 }
 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());
 }
 public function index()
 {
     $tipos = TipoEndereco::find();
     return GetResponse::createResponse($this->request, $tipos->toArray());
 }