public function getItens() { $query = TarefaItens::query()->columns(['id', 'titulo', 'descricao', 'porcentagem', 'status'])->where('id_tarefa = :id_tarefa:')->bind(['id_tarefa' => $this->getId()]); return $query->execute(); }
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; }