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