public function show($id)
 {
     $tarefa = Tarefa::findFirst($id);
     if ($tarefa) {
         $ret['anexos'] = $tarefa->getAnexos()->toArray();
         return $ret;
     } else {
         throw new \Exception("Tarefa #{$id} não encontrada", StatusCodes::NAO_ENCONTRADO);
     }
 }
 public function createTarefaItens(Tarefa $tarefa, $dataPost)
 {
     foreach ($dataPost->add_itens as $postItem) {
         $item = new TarefaItens();
         $item->setDescricao($postItem->descricao);
         $item->setPorcentagem($postItem->porcentagem);
         $item->setTitulo($postItem->titulo);
         $item->setStatus(TarefaItens::STATUS_NAO_CONCLUIDO);
         $item->setIdTarefa($tarefa->getId());
         if (!$item->validation() || !$item->save()) {
             $this->db->rollback();
             throw new \Exception(PostResponse::createModelErrorMessages($item), StatusCodes::ERRO_CLI);
         }
     }
     return true;
 }