From ff58f23bb7bbde52e9680125a1974abd165bcbbd Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 27 May 2026 20:37:45 +0300 Subject: [PATCH] add element youtube url --- backend/app/Controllers/ElementController.php | 1 + backend/app/Element/CreateElementDto.php | 1 + backend/app/Element/Element.php | 6 ++++++ backend/app/Element/ElementModel.php | 3 +++ backend/app/Element/EloquentElementRepository.php | 3 +++ .../app/Element/UseCases/CreateElement/CreateElement.php | 5 +++++ .../Element/UseCases/CreateElement/CreateElementRequest.php | 1 + .../migrations/2026_05_24_000001_elements_table.php | 1 + backend/database/seeders/ElementSeeder.php | 4 ++++ backend/tests/Fakes/FakeElementRepository.php | 2 ++ 10 files changed, 27 insertions(+) diff --git a/backend/app/Controllers/ElementController.php b/backend/app/Controllers/ElementController.php index b485f73..fc03d9e 100644 --- a/backend/app/Controllers/ElementController.php +++ b/backend/app/Controllers/ElementController.php @@ -48,6 +48,7 @@ class ElementController 'description' => $element->getDescription(), 'richText' => $element->getRichText(), 'pdfPath' => $element->getPdfPath(), + 'youtubeUrl' => $element->getYoutubeUrl(), ], ], 200); } diff --git a/backend/app/Element/CreateElementDto.php b/backend/app/Element/CreateElementDto.php index e5cc6fe..cd8bec2 100644 --- a/backend/app/Element/CreateElementDto.php +++ b/backend/app/Element/CreateElementDto.php @@ -12,6 +12,7 @@ class CreateElementDto public string $description, public string $richText, public ?string $pdfPath, + public ?string $youtubeUrl, public ?Element $parentElement, ) { } diff --git a/backend/app/Element/Element.php b/backend/app/Element/Element.php index f8e9f38..f747d12 100644 --- a/backend/app/Element/Element.php +++ b/backend/app/Element/Element.php @@ -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; diff --git a/backend/app/Element/ElementModel.php b/backend/app/Element/ElementModel.php index 2655d04..b246351 100644 --- a/backend/app/Element/ElementModel.php +++ b/backend/app/Element/ElementModel.php @@ -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|ElementModel newModelQuery() @@ -24,6 +25,7 @@ use Illuminate\Database\Eloquent\Model; * @method static Builder|ElementModel whereDescription($value) * @method static Builder|ElementModel whereRichText($value) * @method static Builder|ElementModel wherePdfPath($value) + * @method static Builder|ElementModel whereYoutubeUrl($value) * * @mixin \Eloquent */ @@ -39,6 +41,7 @@ class ElementModel extends Model 'description', 'rich_text', 'pdf_path', + 'youtube_url', 'parent_element_id', ]; diff --git a/backend/app/Element/EloquentElementRepository.php b/backend/app/Element/EloquentElementRepository.php index 389d37b..a957880 100644 --- a/backend/app/Element/EloquentElementRepository.php +++ b/backend/app/Element/EloquentElementRepository.php @@ -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, ); diff --git a/backend/app/Element/UseCases/CreateElement/CreateElement.php b/backend/app/Element/UseCases/CreateElement/CreateElement.php index 364ef0a..c0a8661 100644 --- a/backend/app/Element/UseCases/CreateElement/CreateElement.php +++ b/backend/app/Element/UseCases/CreateElement/CreateElement.php @@ -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, )); } diff --git a/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php b/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php index b63628a..1738838 100644 --- a/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php +++ b/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php @@ -10,6 +10,7 @@ class CreateElementRequest public ?string $description, public ?string $richText, public ?string $pdfPath, + public ?string $youtubeUrl, public ?int $parentElementId, ) { } diff --git a/backend/database/migrations/2026_05_24_000001_elements_table.php b/backend/database/migrations/2026_05_24_000001_elements_table.php index c0edefa..90f708c 100644 --- a/backend/database/migrations/2026_05_24_000001_elements_table.php +++ b/backend/database/migrations/2026_05_24_000001_elements_table.php @@ -15,6 +15,7 @@ return new class extends Migration $table->text('description')->default(''); $table->text('rich_text')->default(''); $table->string('pdf_path')->nullable(); + $table->string('youtube_url')->nullable(); $table->foreignId('parent_element_id') ->nullable() ->constrained('elements'); diff --git a/backend/database/seeders/ElementSeeder.php b/backend/database/seeders/ElementSeeder.php index 592396d..af7ff09 100644 --- a/backend/database/seeders/ElementSeeder.php +++ b/backend/database/seeders/ElementSeeder.php @@ -22,6 +22,8 @@ class ElementSeeder extends Seeder . '

Move steadily from awareness ' . 'to practice.

', pdfPath: '/assets/pdfs/baderech.pdf', + youtubeUrl: 'https://www.youtube.com/watch?v=' + . 'yHx-r4p6hHU&t=1s', parentElement: null, )); $elementRepository->create(new CreateElementDto( @@ -32,6 +34,7 @@ class ElementSeeder extends Seeder richText: '

Avodah foundations begin with honest awareness ' . 'and small repeatable steps.

', pdfPath: null, + youtubeUrl: null, parentElement: $rootElement, )); $elementRepository->create(new CreateElementDto( @@ -41,6 +44,7 @@ class ElementSeeder extends Seeder richText: '

Daily practice turns inspiration into a ' . 'dependable rhythm.

', pdfPath: null, + youtubeUrl: null, parentElement: $rootElement, )); } diff --git a/backend/tests/Fakes/FakeElementRepository.php b/backend/tests/Fakes/FakeElementRepository.php index 0ccdfeb..a877d8b 100644 --- a/backend/tests/Fakes/FakeElementRepository.php +++ b/backend/tests/Fakes/FakeElementRepository.php @@ -23,6 +23,7 @@ class FakeElementRepository implements ElementRepository description: $dto->description, richText: $dto->richText, pdfPath: $dto->pdfPath, + youtubeUrl: $dto->youtubeUrl, set: $dto->set, parentElement: $dto->parentElement, ); @@ -101,6 +102,7 @@ class FakeElementRepository implements ElementRepository description: $element->getDescription(), richText: $element->getRichText(), pdfPath: $element->getPdfPath(), + youtubeUrl: $element->getYoutubeUrl(), set: $element->getSet(), parentElement: $parentElement, );