From acdfc144424a1932e8180aa42cf1c705f5513edf Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 17 Apr 2026 11:03:10 +0300 Subject: [PATCH] create root node on text creation --- app/Text/UseCases/CreateText.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Text/UseCases/CreateText.php b/app/Text/UseCases/CreateText.php index 062497c..bf4715b 100644 --- a/app/Text/UseCases/CreateText.php +++ b/app/Text/UseCases/CreateText.php @@ -5,17 +5,28 @@ namespace App\Text\UseCases; use App\Text\Text; use App\Text\CreateTextDto; use App\Text\TextRepository; +use App\Node\NodeRepository; +use App\Node\CreateNodeDto; class CreateText { public function __construct( private TextRepository $textRepo, + private NodeRepository $nodeRepo, ) {} public function execute(CreateTextRequest $request): Text { - return $this->textRepo->create(new CreateTextDto( + $text = $this->textRepo->create(new CreateTextDto( name: $request->name, )); + + $this->nodeRepo->create(new CreateNodeDto( + text: $text, + title: $text->getName(), + parentNode: null, + )); + + return $text; } }