delete child elements

This commit is contained in:
Yisroel Baum 2026-06-21 22:13:59 +03:00
parent ac0f404fce
commit f4b42973cb
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
10 changed files with 271 additions and 17 deletions

View file

@ -63,6 +63,18 @@ class EloquentElementRepository implements ElementRepository
return $this->toDomain($model);
}
public function delete(Element $element): void
{
$model = ElementModel::find($element->getId());
if ($model === null) {
throw new DomainException(
"Element with id: {$element->getId()} doesnt exist"
);
}
$model->delete();
}
public function find(int $id): ?Element
{
$model = ElementModel::find($id);