public function delete($id = null)
 {
     $dataPost = $this->request->getJsonRawBody();
     foreach ($dataPost->anexos_id as $anexo_id) {
         $anexo = Anexo::findFirst($anexo_id);
         unlink($anexo->getCaminho());
         $anexo->getProjetoAnexos()->delete();
         $anexo->delete();
     }
     return PostResponse::createResponse(true, "Anexos removidos com sucesso");
 }
예제 #2
0
 public function checkToken($token)
 {
     $m = $this->getDI()->get('memcached');
     $data = $m->get($token);
     if ($m->getResultCode() == \Memcached::RES_NOTFOUND) {
         throw new \Exception('Login expirado', StatusCodes::NAO_AUTORIZADO);
     } else {
         $m->set($token, $data, time() + Settings::LOGIN_EXPIRATION);
         return PostResponse::createResponse(true, "Login ativo");
     }
 }
 public function update($id)
 {
     $tarefa = Tarefa::findFirst($id);
     if ($tarefa) {
         $this->db->begin();
         $this->createTarefaFromJsonRawData($tarefa);
         $this->db->commit();
         return PostResponse::createResponse(PostResponse::STATUS_OK, "Tarefa [#{$id} {$tarefa->getNome()}] alterada com sucesso.");
     } else {
         throw new \Exception("Tarefa #{$id} não encontrada", StatusCodes::NAO_ENCONTRADO);
     }
 }
 public function delete($id)
 {
     $cliente = Cliente::findFirst($id);
     if ($cliente) {
         if ($cliente->delete()) {
             return PostResponse::createResponse(PostResponse::STATUS_OK, "Cliente removido com sucesso");
         } else {
             throw new \Exception(PostResponse::createModelErrorMessages($cliente), StatusCodes::ERRO_CLI_CONFLICT);
         }
     } else {
         throw new \Exception("Cliente #{$id} não encontrado", StatusCodes::NAO_ENCONTRADO);
     }
 }
 public function update($id)
 {
     $projeto = Projeto::findFirst($id);
     if ($projeto) {
         $projeto->deleteRelated();
         $projeto = $this->createProjetoFromJsonRawData($projeto);
         if ($projeto->validation() && $projeto->save()) {
             return PostResponse::createResponse(PostResponse::STATUS_OK, "Projeto [#{$projeto->getId()} {$projeto->getNome()}] alterado com sucesso.");
         } else {
             throw new \Exception(PostResponse::createModelErrorMessages($projeto), StatusCodes::ERRO_CLI);
         }
     } else {
         throw new \Exception("Projeto #{$id} não encontrado", StatusCodes::NAO_ENCONTRADO);
     }
 }