add set edits

This commit is contained in:
Yisroel Baum 2026-07-02 17:10:23 +03:00
parent f8e1ef1397
commit 53d4120e83
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
8 changed files with 245 additions and 0 deletions

View file

@ -2,6 +2,8 @@
namespace App\Set;
use DomainException;
class EloquentSetRepository implements SetRepository
{
public function create(CreateSetDto $dto): Set
@ -15,6 +17,35 @@ class EloquentSetRepository implements SetRepository
return $this->toDomain($model);
}
public function update(Set $set): Set
{
$model = SetModel::find($set->getId());
if ($model === null) {
throw new DomainException(
"Set with id: {$set->getId()} doesnt exist"
);
}
$model->name = $set->getName();
$model->description = $set->getDescription();
$model->icon_image_url = $set->getIconImageUrl();
$model->save();
return $this->toDomain($model);
}
public function delete(Set $set): void
{
$model = SetModel::find($set->getId());
if ($model === null) {
throw new DomainException(
"Set with id: {$set->getId()} doesnt exist"
);
}
$model->delete();
}
public function find(int $id): ?Set
{
$model = SetModel::find($id);