add element youtube url

This commit is contained in:
Yisroel Baum 2026-05-27 20:37:45 +03:00
parent f9c4d72e60
commit ff58f23bb7
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
10 changed files with 27 additions and 0 deletions

View file

@ -48,6 +48,7 @@ class ElementController
'description' => $element->getDescription(),
'richText' => $element->getRichText(),
'pdfPath' => $element->getPdfPath(),
'youtubeUrl' => $element->getYoutubeUrl(),
],
], 200);
}

View file

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

View file

@ -12,6 +12,7 @@ class Element
private string $description,
private string $richText,
private ?string $pdfPath,
private ?string $youtubeUrl,
private Set $set,
private ?Element $parentElement,
) {
@ -42,6 +43,11 @@ class Element
return $this->pdfPath;
}
public function getYoutubeUrl(): ?string
{
return $this->youtubeUrl;
}
public function getSet(): Set
{
return $this->set;

View file

@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
* @property string $description
* @property string $rich_text
* @property string|null $pdf_path
* @property string|null $youtube_url
* @property int|null $parent_element_id
*
* @method static Builder<static>|ElementModel newModelQuery()
@ -24,6 +25,7 @@ use Illuminate\Database\Eloquent\Model;
* @method static Builder<static>|ElementModel whereDescription($value)
* @method static Builder<static>|ElementModel whereRichText($value)
* @method static Builder<static>|ElementModel wherePdfPath($value)
* @method static Builder<static>|ElementModel whereYoutubeUrl($value)
*
* @mixin \Eloquent
*/
@ -39,6 +41,7 @@ class ElementModel extends Model
'description',
'rich_text',
'pdf_path',
'youtube_url',
'parent_element_id',
];

View file

@ -20,6 +20,7 @@ class EloquentElementRepository implements ElementRepository
'description' => $dto->description,
'rich_text' => $dto->richText,
'pdf_path' => $dto->pdfPath,
'youtube_url' => $dto->youtubeUrl,
'parent_element_id' => $dto->parentElement?->getId(),
]);
@ -29,6 +30,7 @@ class EloquentElementRepository implements ElementRepository
description: $dto->description,
richText: $dto->richText,
pdfPath: $dto->pdfPath,
youtubeUrl: $dto->youtubeUrl,
set: $dto->set,
parentElement: $dto->parentElement,
);
@ -111,6 +113,7 @@ class EloquentElementRepository implements ElementRepository
description: $model->description,
richText: $model->rich_text,
pdfPath: $model->pdf_path,
youtubeUrl: $model->youtube_url,
set: $set,
parentElement: $parentElement,
);

View file

@ -33,6 +33,9 @@ class CreateElement
$description = $request->description ?? '';
$richText = $request->richText ?? '';
$pdfPath = $request->pdfPath === '' ? null : $request->pdfPath;
$youtubeUrl = $request->youtubeUrl === ''
? null
: $request->youtubeUrl;
$set = $this->setRepo->find($request->setId);
if ($set === null) {
@ -50,6 +53,7 @@ class CreateElement
description: $description,
richText: $richText,
pdfPath: $pdfPath,
youtubeUrl: $youtubeUrl,
parentElement: null,
));
}
@ -74,6 +78,7 @@ class CreateElement
description: $description,
richText: $richText,
pdfPath: $pdfPath,
youtubeUrl: $youtubeUrl,
parentElement: $parentElement,
));
}

View file

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