create text with request dto
This commit is contained in:
parent
6c9abb01d4
commit
a95a8838f6
2 changed files with 31 additions and 0 deletions
21
app/Text/UseCases/CreateText.php
Normal file
21
app/Text/UseCases/CreateText.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Text\UseCases;
|
||||
|
||||
use App\Text\Text;
|
||||
use App\Text\CreateTextDto;
|
||||
use App\Text\TextRepository;
|
||||
|
||||
class CreateText
|
||||
{
|
||||
public function __construct(
|
||||
private TextRepository $textRepo,
|
||||
) {}
|
||||
|
||||
public function execute(CreateTextRequest $request): Text
|
||||
{
|
||||
return $this->textRepo->create(new CreateTextDto(
|
||||
name: $request->name,
|
||||
));
|
||||
}
|
||||
}
|
||||
10
app/Text/UseCases/CreateTextRequest.php
Normal file
10
app/Text/UseCases/CreateTextRequest.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace App\Text\UseCases;
|
||||
|
||||
class CreateTextRequest
|
||||
{
|
||||
public function __construct(
|
||||
public string $name,
|
||||
) {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue