refactor element updates
This commit is contained in:
parent
581852ecbc
commit
d334745ade
19 changed files with 453 additions and 75 deletions
|
|
@ -38,7 +38,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
);
|
||||
}
|
||||
|
||||
public function update(Element $element, UpdateElementDto $dto): Element
|
||||
public function update(Element $element): Element
|
||||
{
|
||||
$model = ElementModel::find($element->getId());
|
||||
if ($model === null) {
|
||||
|
|
@ -47,25 +47,17 @@ class EloquentElementRepository implements ElementRepository
|
|||
);
|
||||
}
|
||||
|
||||
$model->title = $dto->title;
|
||||
$model->description = $dto->description;
|
||||
$model->icon_image_url = $dto->iconImageUrl;
|
||||
$model->rich_text = $dto->richText;
|
||||
$model->pdf_path = $dto->pdfPath;
|
||||
$model->youtube_url = $dto->youtubeUrl;
|
||||
$model->set_id = $element->getSet()->getId();
|
||||
$model->title = $element->getTitle();
|
||||
$model->description = $element->getDescription();
|
||||
$model->icon_image_url = $element->getIconImageUrl();
|
||||
$model->rich_text = $element->getRichText();
|
||||
$model->pdf_path = $element->getPdfPath();
|
||||
$model->youtube_url = $element->getYoutubeUrl();
|
||||
$model->parent_element_id = $element->getParentElement()?->getId();
|
||||
$model->save();
|
||||
|
||||
return new Element(
|
||||
id: $element->getId(),
|
||||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
iconImageUrl: $dto->iconImageUrl,
|
||||
richText: $dto->richText,
|
||||
pdfPath: $dto->pdfPath,
|
||||
youtubeUrl: $dto->youtubeUrl,
|
||||
set: $element->getSet(),
|
||||
parentElement: $element->getParentElement(),
|
||||
);
|
||||
return $this->toDomain($model);
|
||||
}
|
||||
|
||||
public function find(int $id): ?Element
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue