create root node on text creation
This commit is contained in:
parent
37c519fb2a
commit
acdfc14442
1 changed files with 12 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue