diff --git a/app/Domains/Bio/Actions/CreateBioPage.php b/app/Domains/Bio/Actions/CreateBioPage.php new file mode 100644 index 0000000..51aff63 --- /dev/null +++ b/app/Domains/Bio/Actions/CreateBioPage.php @@ -0,0 +1,22 @@ + $workspaceId, + 'slug' => $data['slug'], + 'title' => $data['title'] ?? [], + 'description' => $data['description'] ?? [], + 'theme' => $data['theme'] ?? [], + 'is_published' => $data['is_published'] ?? false, + 'domain_id' => $data['domain_id'] ?? null, + ]); + } +} diff --git a/app/Domains/Bio/Models/BioBlock.php b/app/Domains/Bio/Models/BioBlock.php new file mode 100644 index 0000000..1e40887 --- /dev/null +++ b/app/Domains/Bio/Models/BioBlock.php @@ -0,0 +1,19 @@ + 'array', + ]; + + public function bioPage(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(BioPage::class); + } +} diff --git a/app/Domains/Bio/Models/BioPage.php b/app/Domains/Bio/Models/BioPage.php new file mode 100644 index 0000000..15500c5 --- /dev/null +++ b/app/Domains/Bio/Models/BioPage.php @@ -0,0 +1,48 @@ + 'array', + 'is_published' => 'boolean', + 'ulid' => 'string', + ]; + + protected static function booted(): void + { + static::creating(function (self $model) { + if (empty($model->ulid)) { + $model->ulid = (string) Str::ulid(); + } + }); + } + + public function blocks(): \Illuminate\Database\Eloquent\Relations\HasMany + { + return $this->hasMany(BioBlock::class)->orderBy('position'); + } + + public function workspace(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(\App\Domains\Workspace\Models\Workspace::class); + } + + public function domain(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(\App\Domains\Domain\Models\Domain::class); + } +} diff --git a/app/Http/Controllers/BioPageController.php b/app/Http/Controllers/BioPageController.php new file mode 100644 index 0000000..41bcdc2 --- /dev/null +++ b/app/Http/Controllers/BioPageController.php @@ -0,0 +1,23 @@ +getHost(); + $domain = Domain::where('hostname', $host)->first(); + + $page = BioPage::where('slug', $slug) + ->where('domain_id', $domain?->id) + ->where('is_published', true) + ->with('blocks') + ->firstOrFail(); + + return view('bio.show', compact('page')); + } +} diff --git a/resources/views/bio/show.blade.php b/resources/views/bio/show.blade.php new file mode 100644 index 0000000..aeb35d9 --- /dev/null +++ b/resources/views/bio/show.blade.php @@ -0,0 +1,28 @@ + + +
+ + ++ {{ $page->getTranslation('description', app()->getLocale()) }} +
+ @endif +