restore set creation
This commit is contained in:
parent
4897cc2e20
commit
8ec7af8a1f
3 changed files with 21 additions and 0 deletions
10
backend/app/Set/CreateSetDto.php
Normal file
10
backend/app/Set/CreateSetDto.php
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Set;
|
||||||
|
|
||||||
|
class CreateSetDto
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $name,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,15 @@ namespace App\Set;
|
||||||
|
|
||||||
class EloquentSetRepository implements SetRepository
|
class EloquentSetRepository implements SetRepository
|
||||||
{
|
{
|
||||||
|
public function create(CreateSetDto $dto): Set
|
||||||
|
{
|
||||||
|
$model = SetModel::create([
|
||||||
|
'name' => $dto->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->toDomain($model);
|
||||||
|
}
|
||||||
|
|
||||||
public function find(int $id): ?Set
|
public function find(int $id): ?Set
|
||||||
{
|
{
|
||||||
$model = SetModel::find($id);
|
$model = SetModel::find($id);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ namespace App\Set;
|
||||||
|
|
||||||
interface SetRepository
|
interface SetRepository
|
||||||
{
|
{
|
||||||
|
public function create(CreateSetDto $dto): Set;
|
||||||
|
|
||||||
public function find(int $id): ?Set;
|
public function find(int $id): ?Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue