Inhaltsverwaltung: Bilder, Webseiten-Texte, Ausstattung, FAQ, Hinweis-Banner

- Bilder mit automatischen WebP-Webgrößen (640/1280/2048 px), Sortierung per Drag & Drop, Mehrfach-Upload, Import-Befehl photos:import
- Webseiten-Texte als feste, bearbeitbare Bausteine (config/content.php), Rich-Text bereinigt ausgegeben
- Ausstattung und FAQ aus der bisherigen Webseite übernommen
- Rolle Inhalte hat Zugriff auf alle Webseiten-Bereiche

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 10:19:51 +02:00
1 parent 27ea12901e
commit bb7eb62782
53 files changed
+1963 -1

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use App\Enums\AmenityArea;
use Database\Factories\AmenityFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* One line of the equipment list; highlights are featured on the home page.
*/
#[Fillable(['property_id', 'area', 'name', 'is_highlight', 'sort_order'])]
class Amenity extends Model
{
/** @use HasFactory<AmenityFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'area' => AmenityArea::class,
'is_highlight' => 'boolean',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
/**
* Value of an editable website text; the available keys are defined in config/content.php.
*/
#[Fillable(['key', 'value'])]
class ContentBlock extends Model {}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Database\Factories\FaqFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
#[Fillable(['question', 'answer', 'is_published', 'sort_order'])]
class Faq extends Model
{
/** @use HasFactory<FaqFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_published' => 'boolean',
];
}
/**
* @param Builder<Faq> $query
* @return Builder<Faq>
*/
#[Scope]
protected function published(Builder $query): Builder
{
return $query->where('is_published', true)->orderBy('sort_order');
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use App\Enums\NoticeTone;
use Database\Factories\NoticeFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* A banner shown on the website, optionally limited to a date range.
*/
#[Fillable(['text', 'tone', 'link_url', 'link_label', 'starts_on', 'ends_on', 'is_active'])]
class Notice extends Model
{
/** @use HasFactory<NoticeFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'tone' => NoticeTone::class,
'starts_on' => 'immutable_date',
'ends_on' => 'immutable_date',
'is_active' => 'boolean',
];
}
/**
* Active notices whose date range includes today.
*
* @param Builder<Notice> $query
* @return Builder<Notice>
*/
#[Scope]
protected function visible(Builder $query): Builder
{
return $query
->where('is_active', true)
->where(fn (Builder $query) => $query->whereNull('starts_on')->orWhereDate('starts_on', '<=', today()))
->where(fn (Builder $query) => $query->whereNull('ends_on')->orWhereDate('ends_on', '>=', today()));
}
}
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace App\Models;
use App\Enums\PhotoCategory;
use Database\Factories\PhotoFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Image\Enums\Fit;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
/**
* A website photo. The uploaded original is kept; web sizes are generated as WebP on upload.
*/
#[Fillable(['property_id', 'category', 'alt_text', 'caption', 'is_published', 'sort_order'])]
class Photo extends Model implements HasMedia
{
/** @use HasFactory<PhotoFactory> */
use HasFactory, InteractsWithMedia;
public const COLLECTION = 'image';
/** Generated widths in px, used for srcset. */
public const WIDTHS = ['sm' => 640, 'md' => 1280, 'lg' => 2048];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'category' => PhotoCategory::class,
'is_published' => 'boolean',
];
}
public function registerMediaCollections(): void
{
$this->addMediaCollection(self::COLLECTION)
->singleFile()
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
}
public function registerMediaConversions(?Media $media = null): void
{
foreach (self::WIDTHS as $name => $width) {
$this->addMediaConversion($name)
->fit(Fit::Max, $width, $width)
->format('webp')
->quality(80)
->performOnCollections(self::COLLECTION);
}
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @param Builder<Photo> $query
* @return Builder<Photo>
*/
#[Scope]
protected function published(Builder $query): Builder
{
return $query->where('is_published', true)->orderBy('sort_order');
}
public function url(string $size = 'md'): string
{
return $this->getFirstMediaUrl(self::COLLECTION, $size);
}
/**
* srcset for <img>, e.g. "…-sm.webp 640w, …-md.webp 1280w, …-lg.webp 2048w".
*/
public function srcset(): string
{
return collect(self::WIDTHS)
->map(fn (int $width, string $name): string => $this->url($name).' '.$width.'w')
->implode(', ');
}
}
+8
View File
@@ -69,6 +69,14 @@ public function blockedPeriods(): HasMany
return $this->hasMany(BlockedPeriod::class)->orderBy('starts_on');
}
/**
* @return HasMany<Amenity, $this>
*/
public function amenities(): HasMany
{
return $this->hasMany(Amenity::class)->orderBy('sort_order');
}
/**
* @return HasMany<SpecialOffer, $this>
*/