add element pdf path

This commit is contained in:
Yisroel Baum 2026-05-27 20:19:11 +03:00
parent 6c6b3ad257
commit cc1735ee7b
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
13 changed files with 76 additions and 0 deletions

View file

@ -11,6 +11,7 @@ class CreateElementDto
public string $title,
public string $description,
public string $richText,
public ?string $pdfPath,
public ?Element $parentElement,
) {
}

View file

@ -11,6 +11,7 @@ class Element
private string $title,
private string $description,
private string $richText,
private ?string $pdfPath,
private Set $set,
private ?Element $parentElement,
) {
@ -36,6 +37,11 @@ class Element
return $this->richText;
}
public function getPdfPath(): ?string
{
return $this->pdfPath;
}
public function getSet(): Set
{
return $this->set;

View file

@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Model;
* @property string $title
* @property string $description
* @property string $rich_text
* @property string|null $pdf_path
* @property int|null $parent_element_id
*
* @method static Builder<static>|ElementModel newModelQuery()
@ -22,6 +23,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder<static>|ElementModel whereTitle($value)
* @method static Builder<static>|ElementModel whereDescription($value)
* @method static Builder<static>|ElementModel whereRichText($value)
* @method static Builder<static>|ElementModel wherePdfPath($value)
*
* @mixin \Eloquent
*/
@ -36,6 +38,7 @@ class ElementModel extends Model
'title',
'description',
'rich_text',
'pdf_path',
'parent_element_id',
];

View file

@ -19,6 +19,7 @@ class EloquentElementRepository implements ElementRepository
'title' => $dto->title,
'description' => $dto->description,
'rich_text' => $dto->richText,
'pdf_path' => $dto->pdfPath,
'parent_element_id' => $dto->parentElement?->getId(),
]);
@ -27,6 +28,7 @@ class EloquentElementRepository implements ElementRepository
title: $dto->title,
description: $dto->description,
richText: $dto->richText,
pdfPath: $dto->pdfPath,
set: $dto->set,
parentElement: $dto->parentElement,
);
@ -108,6 +110,7 @@ class EloquentElementRepository implements ElementRepository
title: $model->title,
description: $model->description,
richText: $model->rich_text,
pdfPath: $model->pdf_path,
set: $set,
parentElement: $parentElement,
);

View file

@ -32,6 +32,7 @@ class CreateElement
}
$description = $request->description ?? '';
$richText = $request->richText ?? '';
$pdfPath = $request->pdfPath === '' ? null : $request->pdfPath;
$set = $this->setRepo->find($request->setId);
if ($set === null) {
@ -48,6 +49,7 @@ class CreateElement
title: $request->title,
description: $description,
richText: $richText,
pdfPath: $pdfPath,
parentElement: null,
));
}
@ -71,6 +73,7 @@ class CreateElement
title: $request->title,
description: $description,
richText: $richText,
pdfPath: $pdfPath,
parentElement: $parentElement,
));
}

View file

@ -9,6 +9,7 @@ class CreateElementRequest
public ?string $title,
public ?string $description,
public ?string $richText,
public ?string $pdfPath,
public ?int $parentElementId,
) {
}