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; }