textId; $text = $this->textRepo->find($id); if ($text === null) { throw new DomainException("Text with id: $id doesnt exist"); } if ($request->parentNodeId === null) { return $this->nodeRepo->create(new CreateNodeDto( text: $text, title: $request->title, parentNode: null, )); } $parentNode = $this->nodeRepo->find($request->parentNodeId); return $this->nodeRepo->create(new CreateNodeDto( text: $text, title: $request->title, parentNode: $parentNode, )); } }