add element rich text
This commit is contained in:
parent
827abde41b
commit
457dbbb7de
12 changed files with 63 additions and 5 deletions
|
|
@ -10,6 +10,7 @@ class CreateElementDto
|
|||
public Set $set,
|
||||
public string $title,
|
||||
public string $description,
|
||||
public string $richText,
|
||||
public ?Element $parentElement,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class Element
|
|||
private int $id,
|
||||
private string $title,
|
||||
private string $description,
|
||||
private string $richText,
|
||||
private Set $set,
|
||||
private ?Element $parentElement,
|
||||
) {
|
||||
|
|
@ -30,6 +31,11 @@ class Element
|
|||
return $this->description;
|
||||
}
|
||||
|
||||
public function getRichText(): string
|
||||
{
|
||||
return $this->richText;
|
||||
}
|
||||
|
||||
public function getSet(): Set
|
||||
{
|
||||
return $this->set;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int $set_id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property string $rich_text
|
||||
* @property int|null $parent_element_id
|
||||
*
|
||||
* @method static Builder<static>|ElementModel newModelQuery()
|
||||
|
|
@ -20,6 +21,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static Builder<static>|ElementModel whereSetId($value)
|
||||
* @method static Builder<static>|ElementModel whereTitle($value)
|
||||
* @method static Builder<static>|ElementModel whereDescription($value)
|
||||
* @method static Builder<static>|ElementModel whereRichText($value)
|
||||
*
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
|
|
@ -33,6 +35,7 @@ class ElementModel extends Model
|
|||
'set_id',
|
||||
'title',
|
||||
'description',
|
||||
'rich_text',
|
||||
'parent_element_id',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
'set_id' => $dto->set->getId(),
|
||||
'title' => $dto->title,
|
||||
'description' => $dto->description,
|
||||
'rich_text' => $dto->richText,
|
||||
'parent_element_id' => $dto->parentElement?->getId(),
|
||||
]);
|
||||
|
||||
|
|
@ -25,6 +26,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
id: $model->id,
|
||||
title: $dto->title,
|
||||
description: $dto->description,
|
||||
richText: $dto->richText,
|
||||
set: $dto->set,
|
||||
parentElement: $dto->parentElement,
|
||||
);
|
||||
|
|
@ -105,6 +107,7 @@ class EloquentElementRepository implements ElementRepository
|
|||
id: $model->id,
|
||||
title: $model->title,
|
||||
description: $model->description,
|
||||
richText: $model->rich_text,
|
||||
set: $set,
|
||||
parentElement: $parentElement,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class CreateElement
|
|||
throw new BadRequestException('title is required');
|
||||
}
|
||||
$description = $request->description ?? '';
|
||||
$richText = $request->richText ?? '';
|
||||
|
||||
$set = $this->setRepo->find($request->setId);
|
||||
if ($set === null) {
|
||||
|
|
@ -46,6 +47,7 @@ class CreateElement
|
|||
set: $set,
|
||||
title: $request->title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
parentElement: null,
|
||||
));
|
||||
}
|
||||
|
|
@ -68,6 +70,7 @@ class CreateElement
|
|||
set: $set,
|
||||
title: $request->title,
|
||||
description: $description,
|
||||
richText: $richText,
|
||||
parentElement: $parentElement,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ class CreateElementRequest
|
|||
public ?int $setId,
|
||||
public ?string $title,
|
||||
public ?string $description,
|
||||
public ?string $richText,
|
||||
public ?int $parentElementId,
|
||||
) {
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue