create node with request dto
This commit is contained in:
parent
3ddca5687b
commit
bd1520c2ca
2 changed files with 31 additions and 0 deletions
21
app/Node/UseCases/CreateNode.php
Normal file
21
app/Node/UseCases/CreateNode.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Node\UseCases;
|
||||||
|
|
||||||
|
use App\Node\Node;
|
||||||
|
use App\Node\CreateNodeDto;
|
||||||
|
use App\Node\NodeRepository;
|
||||||
|
|
||||||
|
class CreateNode
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private NodeRepository $nodeRepo,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function execute(CreateNodeRequest $request): Node
|
||||||
|
{
|
||||||
|
return $this->nodeRepo->create(new CreateNodeDto(
|
||||||
|
title: $request->title,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Node/UseCases/CreateNodeRequest.php
Normal file
10
app/Node/UseCases/CreateNodeRequest.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Node\UseCases;
|
||||||
|
|
||||||
|
class CreateNodeRequest
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $title,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue