From cc1735ee7b9a24aa34d8efcdd889366155e2cc91 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 27 May 2026 20:19:11 +0300 Subject: [PATCH] add element pdf path --- backend/app/Controllers/ElementController.php | 1 + backend/app/Element/CreateElementDto.php | 1 + backend/app/Element/Element.php | 6 +++ backend/app/Element/ElementModel.php | 3 ++ .../app/Element/EloquentElementRepository.php | 3 ++ .../UseCases/CreateElement/CreateElement.php | 3 ++ .../CreateElement/CreateElementRequest.php | 1 + .../2026_05_24_000001_elements_table.php | 1 + backend/database/seeders/ElementSeeder.php | 3 ++ backend/tests/Fakes/FakeElementRepository.php | 2 + backend/tests/Feature/SetsEndpointTest.php | 1 + frontend/rabbi_gerzi/src/stores/elements.ts | 1 + .../rabbi_gerzi/src/views/ElementPage.vue | 50 +++++++++++++++++++ 13 files changed, 76 insertions(+) diff --git a/backend/app/Controllers/ElementController.php b/backend/app/Controllers/ElementController.php index 4942d19..b485f73 100644 --- a/backend/app/Controllers/ElementController.php +++ b/backend/app/Controllers/ElementController.php @@ -47,6 +47,7 @@ class ElementController 'title' => $element->getTitle(), 'description' => $element->getDescription(), 'richText' => $element->getRichText(), + 'pdfPath' => $element->getPdfPath(), ], ], 200); } diff --git a/backend/app/Element/CreateElementDto.php b/backend/app/Element/CreateElementDto.php index 1e48b41..e5cc6fe 100644 --- a/backend/app/Element/CreateElementDto.php +++ b/backend/app/Element/CreateElementDto.php @@ -11,6 +11,7 @@ class CreateElementDto public string $title, public string $description, public string $richText, + public ?string $pdfPath, public ?Element $parentElement, ) { } diff --git a/backend/app/Element/Element.php b/backend/app/Element/Element.php index 2c9395a..f8e9f38 100644 --- a/backend/app/Element/Element.php +++ b/backend/app/Element/Element.php @@ -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; diff --git a/backend/app/Element/ElementModel.php b/backend/app/Element/ElementModel.php index a1ffa17..2655d04 100644 --- a/backend/app/Element/ElementModel.php +++ b/backend/app/Element/ElementModel.php @@ -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|ElementModel newModelQuery() @@ -22,6 +23,7 @@ use Illuminate\Database\Eloquent\Model; * @method static Builder|ElementModel whereTitle($value) * @method static Builder|ElementModel whereDescription($value) * @method static Builder|ElementModel whereRichText($value) + * @method static Builder|ElementModel wherePdfPath($value) * * @mixin \Eloquent */ @@ -36,6 +38,7 @@ class ElementModel extends Model 'title', 'description', 'rich_text', + 'pdf_path', 'parent_element_id', ]; diff --git a/backend/app/Element/EloquentElementRepository.php b/backend/app/Element/EloquentElementRepository.php index 455852c..389d37b 100644 --- a/backend/app/Element/EloquentElementRepository.php +++ b/backend/app/Element/EloquentElementRepository.php @@ -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, ); diff --git a/backend/app/Element/UseCases/CreateElement/CreateElement.php b/backend/app/Element/UseCases/CreateElement/CreateElement.php index 47d5684..364ef0a 100644 --- a/backend/app/Element/UseCases/CreateElement/CreateElement.php +++ b/backend/app/Element/UseCases/CreateElement/CreateElement.php @@ -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, )); } diff --git a/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php b/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php index 908a4d6..b63628a 100644 --- a/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php +++ b/backend/app/Element/UseCases/CreateElement/CreateElementRequest.php @@ -9,6 +9,7 @@ class CreateElementRequest public ?string $title, public ?string $description, public ?string $richText, + public ?string $pdfPath, 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 0f96d3a..c0edefa 100644 --- a/backend/database/migrations/2026_05_24_000001_elements_table.php +++ b/backend/database/migrations/2026_05_24_000001_elements_table.php @@ -14,6 +14,7 @@ return new class extends Migration $table->string('title'); $table->text('description')->default(''); $table->text('rich_text')->default(''); + $table->string('pdf_path')->nullable(); $table->foreignId('parent_element_id') ->nullable() ->constrained('elements'); diff --git a/backend/database/seeders/ElementSeeder.php b/backend/database/seeders/ElementSeeder.php index 02d2467..592396d 100644 --- a/backend/database/seeders/ElementSeeder.php +++ b/backend/database/seeders/ElementSeeder.php @@ -21,6 +21,7 @@ class ElementSeeder extends Seeder richText: '

Begin with a clear map for avodah growth.

' . '

Move steadily from awareness ' . 'to practice.

', + pdfPath: '/assets/pdfs/baderech.pdf', parentElement: null, )); $elementRepository->create(new CreateElementDto( @@ -30,6 +31,7 @@ class ElementSeeder extends Seeder . 'avodah practice.', richText: '

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

', + pdfPath: null, parentElement: $rootElement, )); $elementRepository->create(new CreateElementDto( @@ -38,6 +40,7 @@ class ElementSeeder extends Seeder description: 'Practical steps for consistent daily growth.', richText: '

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

', + pdfPath: null, parentElement: $rootElement, )); } diff --git a/backend/tests/Fakes/FakeElementRepository.php b/backend/tests/Fakes/FakeElementRepository.php index 4cf8bce..0ccdfeb 100644 --- a/backend/tests/Fakes/FakeElementRepository.php +++ b/backend/tests/Fakes/FakeElementRepository.php @@ -22,6 +22,7 @@ class FakeElementRepository implements ElementRepository title: $dto->title, description: $dto->description, richText: $dto->richText, + pdfPath: $dto->pdfPath, set: $dto->set, parentElement: $dto->parentElement, ); @@ -99,6 +100,7 @@ class FakeElementRepository implements ElementRepository title: $element->getTitle(), description: $element->getDescription(), richText: $element->getRichText(), + pdfPath: $element->getPdfPath(), set: $element->getSet(), parentElement: $parentElement, ); diff --git a/backend/tests/Feature/SetsEndpointTest.php b/backend/tests/Feature/SetsEndpointTest.php index 32aabd2..ed0bbca 100644 --- a/backend/tests/Feature/SetsEndpointTest.php +++ b/backend/tests/Feature/SetsEndpointTest.php @@ -33,6 +33,7 @@ class SetsEndpointTest extends TestCase title: $baderechSet->getName(), description: $baderechSet->getDescription(), richText: '', + pdfPath: null, parentElement: null, ) ); diff --git a/frontend/rabbi_gerzi/src/stores/elements.ts b/frontend/rabbi_gerzi/src/stores/elements.ts index 6c5f1f4..eb82ffc 100644 --- a/frontend/rabbi_gerzi/src/stores/elements.ts +++ b/frontend/rabbi_gerzi/src/stores/elements.ts @@ -9,6 +9,7 @@ export interface ChildElement { export interface Element extends ChildElement { richText: string + pdfPath: string | null } interface ElementResponse { diff --git a/frontend/rabbi_gerzi/src/views/ElementPage.vue b/frontend/rabbi_gerzi/src/views/ElementPage.vue index 1956a22..10fdbbf 100644 --- a/frontend/rabbi_gerzi/src/views/ElementPage.vue +++ b/frontend/rabbi_gerzi/src/views/ElementPage.vue @@ -56,6 +56,18 @@ watch( v-html="element.richText" /> + +