create root node on text creation

This commit is contained in:
Yisroel Baum 2026-04-17 11:03:10 +03:00
parent 37c519fb2a
commit acdfc14442
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9

View file

@ -5,17 +5,28 @@ namespace App\Text\UseCases;
use App\Text\Text; use App\Text\Text;
use App\Text\CreateTextDto; use App\Text\CreateTextDto;
use App\Text\TextRepository; use App\Text\TextRepository;
use App\Node\NodeRepository;
use App\Node\CreateNodeDto;
class CreateText class CreateText
{ {
public function __construct( public function __construct(
private TextRepository $textRepo, private TextRepository $textRepo,
private NodeRepository $nodeRepo,
) {} ) {}
public function execute(CreateTextRequest $request): Text public function execute(CreateTextRequest $request): Text
{ {
return $this->textRepo->create(new CreateTextDto( $text = $this->textRepo->create(new CreateTextDto(
name: $request->name, name: $request->name,
)); ));
$this->nodeRepo->create(new CreateNodeDto(
text: $text,
title: $text->getName(),
parentNode: null,
));
return $text;
} }
} }