Compare commits

..
Author SHA1 Message Date
LarsandClaude Opus 5.5 1871c04507 Fix: photos uploaded in the admin were stored privately and did not show on the website
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
The admin upload field used Filament's default disk (FILESYSTEM_DISK=local, private), while imports
and the website use the public disk – a photo uploaded in the admin appeared in the photo list but
its web sizes returned 403 (e.g. as floor plan picture). The photo collection and the upload field
now always use the public disk; a data migration moves photos already stored privately (original and
web sizes, folder = media id) to the public disk. Tests for the upload and the migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:12:32 +02:00
LarsandClaude Opus 5.5 dfd3f77a5d Floor plan editor: move corners by drag or arrow keys, insert on edges, delete by double click
Deploy / test (push) Failing after 3s
Deploy / deploy (push) Skipped
Corners stay editable after drawing: drag a corner (mouse or touch), focus it and nudge with the arrow
keys (Shift for larger steps), '+' on an edge inserts a corner in its middle, double click or Delete
removes one. Tested in a browser harness with the real field markup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 16:47:55 +02:00
LarsandClaude Opus 5.5 f7cbc66451 Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
- Table floor_plans (tenant_id, one per apartment, picture = website photo, rooms as JSON with
  corners in percent of the picture), model FloorPlan with BelongsToTenant, Property::floorPlan()
- Admin › Webseite › Grundriss: room list with name, description, photos, equipment (from the
  equipment list), accessibility hint, visibility, and an area editor (click the corners on the picture)
- Section floor_plan: base view without JavaScript (areas jump to the room list), Seebad view with
  room buttons, highlighted area and a cartouche per room (theme.js initFloorPlans)
- Tests: tenant inheritance, point parsing, website output, admin create incl. validation; the
  render test for all themes now includes the floor plan
- Docs: THEMES §5, ZUSAMMENARBEIT §6, STATUS §6 (incl. note for tenancy phase 5)
- styles/grundriss: revised rendering, WebP renditions, room areas of the Stommer flat in percent

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:26:02 +02:00
30 changed files with 1028 additions and 1 deletions

No files matched your search

@@ -0,0 +1,56 @@
<?php
namespace App\Filament\Resources\FloorPlans;
use App\Filament\Concerns\FollowsAdminMode;
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
use App\Filament\Resources\FloorPlans\Pages\EditFloorPlan;
use App\Filament\Resources\FloorPlans\Pages\ListFloorPlans;
use App\Filament\Resources\FloorPlans\Schemas\FloorPlanForm;
use App\Filament\Resources\FloorPlans\Tables\FloorPlansTable;
use App\Models\FloorPlan;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
/**
* Floor plan per apartment: picture from the website photos plus rooms drawn on it (section "Grundriss").
*/
class FloorPlanResource extends Resource
{
use FollowsAdminMode;
protected static ?string $model = FloorPlan::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMap;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Grundriss';
protected static ?string $pluralModelLabel = 'Grundriss';
protected static ?int $navigationSort = 5;
public static function form(Schema $schema): Schema
{
return FloorPlanForm::configure($schema);
}
public static function table(Table $table): Table
{
return FloorPlansTable::configure($table);
}
public static function getPages(): array
{
return [
'index' => ListFloorPlans::route('/'),
'create' => CreateFloorPlan::route('/create'),
'edit' => EditFloorPlan::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Resources\Pages\CreateRecord;
class CreateFloorPlan extends CreateRecord
{
protected static string $resource = FloorPlanResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditFloorPlan extends EditRecord
{
protected static string $resource = FloorPlanResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\FloorPlans\Pages;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListFloorPlans extends ListRecords
{
protected static string $resource = FloorPlanResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,81 @@
<?php
namespace App\Filament\Resources\FloorPlans\Schemas;
use App\Filament\Forms\Components\PhotoSelect;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Property;
use Closure;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Components\ViewField;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class FloorPlanForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => Property::query()->value('id'))
->unique(ignoreRecord: true)
->validationMessages(['unique' => 'Für diese Wohnung gibt es schon einen Grundriss.'])
->required()
->live(),
PhotoSelect::make('photo_id')
->label('Grundriss-Bild')
->helperText('Rendering oder Plan aus Webseite › Fotos. Ein neues Bild im gleichen Ausschnitt behält die Räume.')
->required()
->live(),
Repeater::make('rooms')
->label('Räume')
->columnSpanFull()
->defaultItems(0)
->addActionLabel('Raum hinzufügen')
->reorderable()
->collapsible()
->itemLabel(fn (array $state): string => filled($state['name'] ?? null) ? $state['name'] : 'Neuer Raum')
->columns(2)
->schema([
Hidden::make('id')->default(fn (): string => (string) Str::uuid()),
TextInput::make('name')->label('Name')->placeholder('z. B. Schlafzimmer')->required()->maxLength(60)->live(onBlur: true),
Toggle::make('is_visible')->label('Auf der Website zeigen')->default(true)->inline(false),
ViewField::make('points')
->label('Fläche auf dem Grundriss')
->view('filament.forms.floor-plan-area')
->columnSpanFull()
->rules([
fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void {
if (count(FloorPlan::points(is_string($value) ? $value : null)) < 3) {
$fail('Bitte mindestens drei Ecken des Raums auf dem Bild anklicken.');
}
},
]),
Textarea::make('description')->label('Beschreibung')->rows(3)->maxLength(400)->columnSpanFull(),
PhotoSelect::make('photo_ids')->label('Fotos')->multiple()->helperText('Das erste Foto steht oben, die weiteren als kleine Bilder darunter.'),
Select::make('amenity_ids')
->label('Ausstattung')
->multiple()
->searchable()
->options(fn (Get $get): array => Amenity::query()->where('property_id', $get('../../property_id'))->orderBy('sort_order')->pluck('name', 'id')->all())
->helperText('Aus Webseite › Ausstattung – nichts doppelt pflegen.'),
TextInput::make('hint')
->label('Hinweis zur Barrierefreiheit (optional)')
->placeholder('z. B. Flache Dusche mit kleiner Kante')
->maxLength(160)
->columnSpanFull(),
]),
]);
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Filament\Resources\FloorPlans\Tables;
use App\Models\FloorPlan;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class FloorPlansTable
{
public static function configure(Table $table): Table
{
return $table
->paginated(false)
->columns([
TextColumn::make('property.name')->label('Wohnung'),
TextColumn::make('rooms')->label('Räume')
->state(fn (FloorPlan $record): string => $record->visibleRooms()->pluck('name')->implode(', ') ?: 'noch keine'),
TextColumn::make('updated_at')->label('Geändert')->since(),
])
->recordActions([
EditAction::make(),
]);
}
}
@@ -21,6 +21,7 @@ public static function configure(Schema $schema): Schema
SpatieMediaLibraryFileUpload::make('image')
->label('Bild')
->collection(Photo::COLLECTION)
->disk('public')
->image()
->imageEditor()
->maxSize(25 * 1024)
+81
View File
@@ -0,0 +1,81 @@
<?php
namespace App\Models;
use App\Models\Concerns\BelongsToTenant;
use Database\Factories\FloorPlanFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Collection;
/**
* Floor plan of an apartment: a picture (rendering or scan) from the website photos and the rooms drawn
* on it. Room corners are stored in percent of the picture, so the areas fit every picture size.
*
* @property list<array{id?: string, name?: string, description?: string, hint?: string, points?: string, photo_ids?: list<int|string>, amenity_ids?: list<int|string>, is_visible?: bool}>|null $rooms
*/
#[Fillable(['property_id', 'photo_id', 'rooms'])]
class FloorPlan extends Model
{
/** @use HasFactory<FloorPlanFactory> */
use BelongsToTenant, HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'rooms' => 'array',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @return BelongsTo<Photo, $this>
*/
public function photo(): BelongsTo
{
return $this->belongsTo(Photo::class);
}
/**
* Rooms shown on the website: visible and with an area of at least three corners.
*
* @return Collection<int, array<string, mixed>>
*/
public function visibleRooms(): Collection
{
return collect($this->rooms ?? [])
->filter(fn (array $room): bool => ($room['is_visible'] ?? true) && filled($room['name'] ?? null) && count(self::points($room['points'] ?? null)) >= 3)
->values();
}
/**
* Parses "x,y x,y …" (percent) into points, ignoring anything outside 0–100.
*
* @return list<array{float, float}>
*/
public static function points(?string $points): array
{
$parsed = [];
foreach (preg_split('/\s+/', trim((string) $points)) ?: [] as $pair) {
if (preg_match('/^(\d{1,3}(?:\.\d+)?),(\d{1,3}(?:\.\d+)?)$/', $pair, $match) && (float) $match[1] <= 100 && (float) $match[2] <= 100) {
$parsed[] = [(float) $match[1], (float) $match[2]];
}
}
return $parsed;
}
}
+2
View File
@@ -45,7 +45,9 @@ protected function casts(): array
public function registerMediaCollections(): void
{
// Website photos are public files; the app's default disk (FILESYSTEM_DISK=local) is private.
$this->addMediaCollection(self::COLLECTION)
->useDisk('public')
->singleFile()
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
}
+9
View File
@@ -10,6 +10,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* A rentable holiday apartment. All money amounts are stored in euro cents.
@@ -115,6 +116,14 @@ public function amenities(): HasMany
return $this->hasMany(Amenity::class)->orderBy('sort_order');
}
/**
* @return HasOne<FloorPlan, $this>
*/
public function floorPlan(): HasOne
{
return $this->hasOne(FloorPlan::class);
}
/**
* @return HasMany<SpecialOffer, $this>
*/
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\Permission;
class FloorPlanPolicy extends RolePolicy
{
protected function permission(): Permission
{
return Permission::Content;
}
}
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace App\Themes\Sections;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Photo;
use App\Themes\Theme;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Str;
/**
* Interactive floor plan of the apartment (Admin › Webseite › Grundriss): guests tap a room and see its
* photos, equipment and accessibility hint. Without JavaScript the rooms are listed below the plan.
*/
class FloorPlanSection extends Section
{
public static function key(): string
{
return 'floor_plan';
}
public static function label(): string
{
return 'Grundriss (interaktiv)';
}
public static function icon(): string
{
return 'heroicon-o-map';
}
public static function schema(): array
{
return [
TextInput::make('heading')->label('Überschrift')->default('Der Grundriss')->maxLength(120)
->helperText('Bild und Räume pflegen Sie unter Webseite › Grundriss.'),
Textarea::make('text')->label('Text')->rows(2)->maxLength(300)
->default('Tippen Sie auf einen Raum, um Fotos und Ausstattung zu sehen.'),
];
}
public function data(Theme $theme, array $data): array
{
$plan = $theme->property()?->floorPlan()->with('photo')->first();
$rooms = $plan?->photo ? $plan->visibleRooms() : collect();
$photos = Photo::query()->published()->with('media')
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['photo_ids'] ?? [])->unique()->all())
->get()->keyBy('id');
$amenities = Amenity::query()
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['amenity_ids'] ?? [])->unique()->all())
->pluck('name', 'id');
return [
'heading' => $data['heading'] ?? 'Der Grundriss',
'text' => $data['text'] ?? null,
'photo' => $plan?->photo,
'rooms' => $rooms->map(fn (array $room, int $index): array => [
'key' => 'raum-'.Str::slug($room['name']).'-'.($index + 1),
'name' => $room['name'],
'description' => $room['description'] ?? null,
'hint' => $room['hint'] ?? null,
'points' => collect(FloorPlan::points($room['points']))->map(fn (array $point): string => $point[0].','.$point[1])->implode(' '),
'photos' => collect($room['photo_ids'] ?? [])->map(fn ($id) => $photos->get((int) $id))->filter()->values(),
'amenities' => collect($room['amenity_ids'] ?? [])->map(fn ($id) => $amenities->get((int) $id))->filter()->values(),
]),
];
}
}
+1
View File
@@ -39,6 +39,7 @@
Sections\TextImageSection::class,
Sections\GallerySection::class,
Sections\AmenitiesSection::class,
Sections\FloorPlanSection::class,
Sections\LocationSection::class,
Sections\PricesSection::class,
Sections\OffersSection::class,
+32
View File
@@ -0,0 +1,32 @@
<?php
namespace Database\Factories;
use App\Models\FloorPlan;
use App\Models\Photo;
use App\Models\Property;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends Factory<FloorPlan>
*/
class FloorPlanFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'property_id' => Property::factory(),
'photo_id' => Photo::factory(),
'rooms' => [
['id' => (string) Str::uuid(), 'name' => 'Wohnbereich', 'description' => 'Helles Wohnzimmer mit Ledersofa.', 'hint' => null, 'points' => '10,20 50,20 50,65 10,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
['id' => (string) Str::uuid(), 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65 50,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
],
];
}
}
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* One floor plan per apartment: a picture from the website photos and the rooms drawn on it.
*/
public function up(): void
{
Schema::create('floor_plans', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
$table->foreignId('property_id')->unique()->constrained()->cascadeOnDelete();
$table->foreignId('photo_id')->nullable()->constrained()->nullOnDelete();
$table->json('rooms')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('floor_plans');
}
};
@@ -0,0 +1,48 @@
<?php
use App\Models\Photo;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
return new class extends Migration
{
/**
* Photos uploaded in the admin landed on the private default disk ("local"), so the website could not
* show them. Moves their files (original and web sizes, folder = media id) to the public disk.
* Safe to run again: only media not yet on the public disk are touched.
*/
public function up(): void
{
$media = DB::table('media')
->where('model_type', Photo::class)
->where(fn ($query) => $query->where('disk', '!=', 'public')->orWhere('conversions_disk', '!=', 'public'))
->get(['id', 'disk', 'conversions_disk']);
foreach ($media as $item) {
$folder = (string) $item->id;
$public = Storage::disk('public');
$disks = array_values(array_diff(array_unique([$item->disk, $item->conversions_disk ?: $item->disk]), ['public']));
if (array_filter($disks, fn (string $diskName): bool => config("filesystems.disks.{$diskName}") === null) !== []) {
continue;
}
foreach ($disks as $diskName) {
$source = Storage::disk($diskName);
foreach ($source->allFiles($folder) as $file) {
$public->writeStream($file, $source->readStream($file));
}
$source->deleteDirectory($folder);
}
DB::table('media')->where('id', $item->id)->update(['disk' => 'public', 'conversions_disk' => 'public']);
}
}
public function down(): void
{
// Files stay public; moving them back to a private disk would hide them from the website again.
}
};
+1 -1
View File
@@ -121,7 +121,7 @@ ## 6. Design-Theme „Seebad“ (Abschnitt der Design-Session)
| Baustein | Daten / Admin | Darstellung | Abhängig von |
|---|---|---|---|
| Interaktiver Grundriss | je Wohnung: Grundriss (SVG/Bild) + Räume (Name, Text, Fotos, Fläche als Polygon in %); Editor im Admin | Inline-SVG, Räume antippen → Foto/Text; ohne JS als Liste | Mandanten-Umbau Phase 1 (Daten je Wohnung/Mandant) |
| Interaktiver Grundriss – **gebaut** (23.10.2026, Branch `feature/bausteine`) | Tabelle `floor_plans` (`tenant_id`, eine je Wohnung, Bild = Foto aus Webseite › Fotos, Räume als JSON: Name, Text, Hinweis, Fotos, Ausstattung, sichtbar, Ecken in %); Admin › Webseite › Grundriss mit Eckpunkt-Editor (Ecken setzen, ziehen, mit Pfeiltasten feinjustieren, auf Kanten einfügen, per Doppelklick/Entf löschen) (`resources/views/filament/forms/floor-plan-area.blade.php`, nur Expertenansicht) | Baustein `floor_plan`; Seebad: Flächen und Raum-Tasten wählen einen Raum, Kartusche mit Foto/Ausstattung/Hinweis; ohne JS Liste. Rendering: `styles/grundriss/` | **Mandanten Phase 5:** `floor_plans` beim Export/Löschen eines Mandanten mitnehmen |
| Tipps der Gastgeberin | eigene Liste je Website (Ort, Kategorie, Weg/Gehzeit, Text, Foto, Karten-Link, Saison) | Liste mit Vignette je Kategorie | Bildwelt (Vignetten je Kategorie) |
| Gut zu wissen | strukturierte Felder an der Wohnung (Zugang, Dusche, Haustiere, An-/Abreise, Parken) – auch für Angebot/Mail/JSON-LD | Kartusche | – (klein) |
| Belegungs-/Preiskalender (nur ansehen) | vorhandene Daten (`AvailabilityChecker`, `PriceCalculator`) | Monatsansicht, Livewire oder statisch gerendert | – |
+1
View File
@@ -106,6 +106,7 @@ ## 5. Bausteinkatalog – Vertrag der Vorlagen
| `text_image` | Text mit Bildern | `$eyebrow`, `$heading`, `$text` (HtmlString\|null), `$photos` (≤3), `$imagePosition` (`left`\|`right`), `$linkLabel`, `$linkUrl` |
| `gallery` | Bildergalerie | `$heading`, `$photos` – Lightbox: `<a href="{{ $photo->url('lg') }}" data-lightbox data-alt="…">` |
| `amenities` | Ausstattung | `$heading`, `$groups` (Bereich ⇒ Collection<Amenity>) |
| `floor_plan` | Grundriss (interaktiv) | `$heading`, `$text`, `$photo` (Grundriss-Bild, `Photo`), `$rooms` (Collection von Arrays: `key` – Anker-ID, `name`, `description`, `hint` – Barrierefreiheit, `points` – „x,y x,y …“ in **Prozent** des Bildes → SVG `viewBox="0 0 100 100" preserveAspectRatio="none"` über dem Bild, `photos` – Collection<Photo>, `amenities` – Collection<string>). Rendert nichts ohne Bild oder Räume. Daten: Admin › Webseite › Grundriss (`FloorPlan`) |
| `location` | Lage & Umgebung | `$eyebrow`, `$heading`, `$text`, `$address`, `$mapUrl` (OpenStreetMap-Link, keine eingebettete Karte), `$photos` |
| `prices` | Preise & Saisons | `$eyebrow`, `$heading`, `$text`, `$property`, `$seasons` (nächste 12 Monate), `$extras`, `$featuredSeason` (Name des Erscheinungsbilds) |
| `offers` | Sonderangebote | `$heading`, `$display` (`grid`\|`list`\|`rotating`), `$offers` (Collection<`App\Pricing\AdvertisedOffer`>: `title`, `description`, `advantage`, `conditions`, `arrival`/`departure`/`nights()` bei festen Terminen und Lücken, `quote` + `regularTotal()` für „statt …“, `bookingUrl()`). Rollierend: `data-rotator`, `data-rotator-slide`, `data-rotator-prev/next/dot` (theme.js) |
+1
View File
@@ -88,4 +88,5 @@ ## 6. Änderungsprotokoll Vorlagen-Vertrag
| 22.10.2026 | Markengrafiken: `@include('theme::partials.brand', ['name' => 'mark', 'class' => '…'])` (mark, logo, wave-divider, icon-apartment/-sea/-terrace/-location); Farben über `--brand-navy/-teal/-wave/-sun` (navy = Textfarbe) | header, footer, facts, location, image |
| 22.10.2026 | `hero`: `$featuredOffer` (wichtigstes hervorgehobenes Angebot oder null) | sections/hero |
| 22.10.2026 | `offers`: `$display` (grid/list/rotating), `$offers` = `AdvertisedOffer` (Termin, Preis, `bookingUrl()`); rollierend über `data-rotator*` | sections/offers |
| 23.10.2026 | **Neuer Baustein `floor_plan`** (Grundriss interaktiv): Vertrag in THEMES.md §5; Basis-Vorlage `ostsee-licht/views/sections/floor_plan.blade.php` (ohne JS: Flächen springen zur Raumliste), Seebad interaktiv (`theme.js` `initFloorPlans`). Neue Themes brauchen keine eigene Vorlage (Vererbung) | sections/floor_plan |
| 22.10.2026 | Seiten außerhalb der Bausteine, die das Theme-Layout nutzen: Angebotsseite `resources/views/offer.blade.php`, Bewertung `resources/views/review.blade.php` – beim Theme-Test mitprüfen | layouts/app |
@@ -0,0 +1,42 @@
{{--
Contract: $heading, $text, $photo (App\Models\Photo, the plan picture), $rooms (Collection of arrays: key, name,
description, hint, points = "x,y x,y …" in percent of the picture, photos = Collection<Photo>, amenities = Collection<string>).
Base version without JavaScript: the areas on the plan jump to the room descriptions below.
--}}
@if ($photo && $rooms->isNotEmpty())
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8" aria-labelledby="{{ $sectionId }}-title">
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
@if ($text)<p class="mt-3 max-w-2xl text-muted">{{ $text }}</p>@endif
<div class="relative mt-8">
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1280px) 80rem, 100vw', 'class' => 'h-auto w-full'])
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" aria-label="Räume im Grundriss">
@foreach ($rooms as $room)
<a href="#{{ $room['key'] }}" aria-label="{{ $room['name'] }}">
<polygon points="{{ $room['points'] }}" class="fill-accent/0 stroke-accent transition hover:fill-accent/20" stroke-width="0.25" vector-effect="non-scaling-stroke"><title>{{ $room['name'] }}</title></polygon>
</a>
@endforeach
</svg>
</div>
<ul class="mt-10 grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
@foreach ($rooms as $room)
<li id="{{ $room['key'] }}" class="scroll-mt-24 rounded bg-surface p-6">
@if ($room['photos']->isNotEmpty())
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 25vw, 100vw', 'class' => 'mb-4 h-44 w-full rounded-sm object-cover'])
@endif
<h3 class="font-display text-2xl">{{ $room['name'] }}</h3>
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
@if ($room['amenities']->isNotEmpty())
<ul class="mt-3 space-y-1 text-muted">
@foreach ($room['amenities'] as $amenity)
<li class="flex gap-2"><span aria-hidden="true" class="text-accent">·</span>{{ $amenity }}</li>
@endforeach
</ul>
@endif
@if ($room['hint'])<p class="mt-3 border-l-2 border-accent pl-3 text-sm">{{ $room['hint'] }}</p>@endif
</li>
@endforeach
</ul>
</section>
@endif
+47
View File
@@ -50,3 +50,50 @@ function initMenuPanels() {
}
initMenuPanels();
/**
* Floor plan (sections/floor_plan): one room at a time. Areas and room buttons select a room; on narrow
* screens the description below the plan is scrolled into view. Without JavaScript all rooms are listed.
*/
function initFloorPlans() {
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
document.querySelectorAll('[data-floor-plan]').forEach((plan) => {
const rooms = [...plan.querySelectorAll('[data-floor-room]')];
const links = [...plan.querySelectorAll('[data-floor-room-link]')];
if (rooms.length === 0) {
return;
}
const select = (key, scroll) => {
rooms.forEach((room) => {
room.hidden = room.id !== key;
});
links.forEach((link) => {
const active = link.dataset.floorRoomLink === key;
link.toggleAttribute('data-active', active);
if (active) {
link.setAttribute('aria-current', 'true');
} else {
link.removeAttribute('aria-current');
}
});
const room = rooms.find((candidate) => candidate.id === key);
if (scroll && room && room.getBoundingClientRect().top > window.innerHeight) {
room.scrollIntoView({ behavior: reduceMotion ? 'auto' : 'smooth', block: 'nearest' });
}
};
links.forEach((link) => {
link.addEventListener('click', (event) => {
event.preventDefault();
select(link.dataset.floorRoomLink, true);
});
});
const fromHash = rooms.find((room) => `#${room.id}` === window.location.hash);
select((fromHash ?? rooms[0]).id, false);
});
}
initFloorPlans();
@@ -0,0 +1,67 @@
{{--
Contract: $heading, $text, $photo, $rooms (see ostsee-licht/views/sections/floor_plan.blade.php).
theme.js (initFloorPlans) shows one room at a time; without JavaScript all rooms are listed and the areas jump to them.
--}}
@if ($photo && $rooms->isNotEmpty())
<section class="mx-auto max-w-7xl px-4 py-16 sm:px-8 sm:py-20" aria-labelledby="{{ $sectionId }}-title" data-floor-plan>
<div class="flex flex-wrap items-end justify-between gap-x-12 gap-y-3">
<h2 id="{{ $sectionId }}-title" class="heading-display">{{ $heading }}</h2>
@if ($text)<p class="max-w-[44ch] text-muted">{{ $text }}</p>@endif
</div>
<div class="mt-10 flex flex-wrap items-start gap-10">
<div class="min-w-0 flex-[999_1_38rem]">
<div class="border-2 border-ink bg-surface p-2 sm:p-4">
<div class="relative">
@include('theme::partials.image', ['photo' => $photo, 'sizes' => '(min-width: 1024px) 60vw, 100vw', 'class' => 'h-auto w-full'])
<svg viewBox="0 0 100 100" preserveAspectRatio="none" class="absolute inset-0 size-full" role="group" aria-label="Räume im Grundriss">
@foreach ($rooms as $room)
<a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}" aria-label="{{ $room['name'] }}" class="group">
<polygon points="{{ $room['points'] }}" vector-effect="non-scaling-stroke"
class="fill-accent/0 stroke-accent/50 [stroke-width:2] transition group-hover:fill-accent/15 group-focus-visible:fill-accent/20 group-data-[active]:fill-accent/25 group-data-[active]:stroke-accent group-data-[active]:[stroke-width:3]"><title>{{ $room['name'] }}</title></polygon>
</a>
@endforeach
</svg>
</div>
</div>
<nav aria-label="Raum wählen" class="mt-5">
<ul class="flex flex-wrap gap-2.5">
@foreach ($rooms as $room)
<li><a href="#{{ $room['key'] }}" data-floor-room-link="{{ $room['key'] }}"
class="inline-flex min-h-12 items-center rounded-full border-2 border-ink bg-surface px-5 font-semibold hover:bg-ink/5 data-[active]:bg-ink data-[active]:text-ground">{{ $room['name'] }}</a></li>
@endforeach
</ul>
</nav>
</div>
<div class="min-w-0 flex-[1_1_22rem] space-y-12">
@foreach ($rooms as $room)
<article id="{{ $room['key'] }}" data-floor-room class="cartouche scroll-mt-28 px-6 pt-10 pb-7 sm:px-7" aria-labelledby="{{ $room['key'] }}-name">
<span class="absolute -top-0.5 -left-0.5" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
<span class="absolute -top-0.5 -right-0.5 -scale-x-100" aria-hidden="true">@include('theme::partials.motif', ['slot' => 'bracket', 'class' => 'size-9'])</span>
@if ($room['photos']->isNotEmpty())
@include('theme::partials.image', ['photo' => $room['photos']->first(), 'sizes' => '(min-width: 1024px) 26rem, 100vw', 'class' => 'mb-5 h-56 w-full rounded object-cover'])
@endif
<h3 id="{{ $room['key'] }}-name" class="font-display text-[2rem] leading-tight">{{ $room['name'] }}</h3>
@if ($room['description'])<p class="mt-2 text-muted">{{ $room['description'] }}</p>@endif
@if ($room['amenities']->isNotEmpty())
<ul class="mt-4 space-y-1.5">
@foreach ($room['amenities'] as $amenity)
<li class="flex gap-3"><x-heroicon-o-check class="mt-1 size-5 shrink-0 text-accent" aria-hidden="true" />{{ $amenity }}</li>
@endforeach
</ul>
@endif
@if ($room['hint'])<p class="mt-5 border-l-[3px] border-accent bg-ground px-4 py-3">{{ $room['hint'] }}</p>@endif
@if ($room['photos']->count() > 1)
<ul class="mt-5 grid grid-cols-3 gap-2">
@foreach ($room['photos']->skip(1) as $more)
<li><a href="{{ $more->url('lg') }}" data-lightbox data-alt="{{ $more->alt_text }}" class="block overflow-hidden rounded">@include('theme::partials.image', ['photo' => $more, 'sizes' => '8rem', 'class' => 'h-20 w-full object-cover'])</a></li>
@endforeach
</ul>
@endif
</article>
@endforeach
</div>
</div>
</section>
@endif
@@ -0,0 +1,115 @@
{{--
Room area editor (FloorPlanForm): click the corners of a room on the plan picture; stored as "x,y x,y …" in
percent of the picture. The other rooms are shown as blue outlines for orientation.
--}}
@php
$planPhoto = \App\Models\Photo::query()->find($get('../../photo_id'));
$currentRoomId = $get('id');
$otherAreas = collect($get('../../rooms') ?? [])
->reject(fn ($room): bool => ($room['id'] ?? null) === $currentRoomId)
->map(fn ($room): string => collect(\App\Models\FloorPlan::points($room['points'] ?? null))->map(fn ($point): string => $point[0].','.$point[1])->implode(' '))
->filter()
->values();
@endphp
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
@if (! $planPhoto)
<p style="padding:.75rem 1rem;border-radius:.5rem;background:#fef3c7;color:#92400e">Bitte oben zuerst das Grundriss-Bild wählen.</p>
@else
<div
x-data="{
state: $wire.$entangle('{{ $getStatePath() }}'),
dragging: null,
pairs() {
return String(this.state ?? '').trim().split(/\s+/)
.filter((pair) => /^\d+(\.\d+)?,\d+(\.\d+)?$/.test(pair))
.map((pair) => pair.split(',').map(Number))
},
write(pairs) { this.state = pairs.map(([x, y]) => x + ',' + y).join(' ') },
clamp(value) { return Math.min(100, Math.max(0, Math.round(value * 10) / 10)) },
position(event) {
const box = this.$refs.plan.getBoundingClientRect()
return [this.clamp((event.clientX - box.left) / box.width * 100), this.clamp((event.clientY - box.top) / box.height * 100)]
},
midpoints() {
const pairs = this.pairs()
if (pairs.length < 2) return []
return pairs.map((a, index) => {
const b = pairs[(index + 1) % pairs.length]
return { index, x: this.clamp((a[0] + b[0]) / 2), y: this.clamp((a[1] + b[1]) / 2) }
}).slice(0, pairs.length === 2 ? 1 : pairs.length)
},
add(event) {
this.write([...this.pairs(), this.position(event)])
},
startDrag(index, event) {
this.dragging = index
event.target.setPointerCapture(event.pointerId)
},
drag(event) {
if (this.dragging === null) return
const pairs = this.pairs()
pairs[this.dragging] = this.position(event)
this.write(pairs)
},
endDrag() { this.dragging = null },
insert(index) {
const pairs = this.pairs()
const middle = this.midpoints().find((point) => point.index === index)
pairs.splice(index + 1, 0, [middle.x, middle.y])
this.write(pairs)
},
remove(index) {
const pairs = this.pairs()
pairs.splice(index, 1)
this.write(pairs)
},
nudge(index, dx, dy, event) {
const step = event.shiftKey ? 1 : 0.2
const pairs = this.pairs()
pairs[index] = [this.clamp(pairs[index][0] + dx * step), this.clamp(pairs[index][1] + dy * step)]
this.write(pairs)
},
undo() { this.write(this.pairs().slice(0, -1)) },
clear() { this.state = '' },
}"
>
<div x-ref="plan" x-on:click="add($event)" x-on:pointermove="drag($event)" x-on:pointerup="endDrag()" x-on:pointercancel="endDrag()"
style="position:relative;cursor:crosshair;user-select:none;touch-action:none;border:1px solid #e4e4e7;border-radius:.5rem;overflow:hidden">
<img src="{{ $planPhoto->url('lg') }}" alt="" draggable="false" style="display:block;width:100%;height:auto">
<svg viewBox="0 0 100 100" preserveAspectRatio="none" style="position:absolute;inset:0;width:100%;height:100%;pointer-events:none" aria-hidden="true">
@foreach ($otherAreas as $area)
<polygon points="{{ $area }}" fill="rgba(37,99,235,.10)" stroke="#2563eb" stroke-width="1.5" vector-effect="non-scaling-stroke" />
@endforeach
<polygon x-bind:points="pairs().map((pair) => pair.join(',')).join(' ')" fill="rgba(217,119,6,.28)" stroke="#d97706" stroke-width="2.5" vector-effect="non-scaling-stroke" />
</svg>
<template x-for="point in midpoints()" x-bind:key="'m' + point.index">
<button type="button" x-on:click.stop="insert(point.index)" x-bind:aria-label="'Punkt zwischen Ecke ' + (point.index + 1) + ' und der nächsten einfügen'" title="Punkt einfügen"
x-bind:style="`position:absolute;left:${point.x}%;top:${point.y}%;width:18px;height:18px;margin:-9px 0 0 -9px;padding:0;border-radius:999px;border:1.5px solid #d97706;background:rgba(255,255,255,.85);color:#b45309;font:600 13px/1 sans-serif;cursor:copy`">+</button>
</template>
<template x-for="(pair, index) in pairs()" x-bind:key="'p' + index">
<button type="button"
x-on:pointerdown.stop="startDrag(index, $event)"
x-on:click.stop
x-on:dblclick.stop="remove(index)"
x-on:keydown.arrow-left.prevent="nudge(index, -1, 0, $event)"
x-on:keydown.arrow-right.prevent="nudge(index, 1, 0, $event)"
x-on:keydown.arrow-up.prevent="nudge(index, 0, -1, $event)"
x-on:keydown.arrow-down.prevent="nudge(index, 0, 1, $event)"
x-on:keydown.delete.prevent="remove(index)"
x-bind:aria-label="'Ecke ' + (index + 1) + ' – ziehen oder mit den Pfeiltasten verschieben, Entf löscht'"
x-bind:title="'Ecke ' + (index + 1)"
x-bind:style="`position:absolute;left:${pair[0]}%;top:${pair[1]}%;width:16px;height:16px;margin:-8px 0 0 -8px;padding:0;background:${dragging === index ? '#d97706' : '#fff'};border:2px solid #d97706;border-radius:3px;cursor:${dragging === index ? 'grabbing' : 'grab'};touch-action:none`"></button>
</template>
</div>
<div style="display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;margin-top:.5rem">
<span style="font-size:.875rem;color:#52525b" x-text="pairs().length + (pairs().length === 1 ? ' Eckpunkt' : ' Eckpunkte')"></span>
<x-filament::button size="sm" color="gray" x-on:click="undo()" x-bind:disabled="pairs().length === 0">Letzten Punkt entfernen</x-filament::button>
<x-filament::button size="sm" color="danger" outlined x-on:click="clear()" x-bind:disabled="pairs().length === 0">Fläche leeren</x-filament::button>
</div>
<p style="margin-top:.25rem;font-size:.875rem;color:#71717a">
Neue Ecke: auf das Bild klicken. Ecke verschieben: Punkt mit der Maus ziehen oder anklicken und mit den Pfeiltasten bewegen (mit Umschalt in größeren Schritten).
Ecke einfügen: „+“ auf einer Kante. Ecke löschen: Doppelklick auf den Punkt oder Entf. Blau umrandet: die anderen Räume.
</p>
</div>
@endif
</x-dynamic-component>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 1.7 MiB

+89
View File
@@ -0,0 +1,89 @@
[
{
"id": "terrasse",
"name": "Terrasse",
"description": "Eigene, überdachte Terrasse mit Gartenmöbeln. Im Frühsommer blühen die Rhododendren direkt davor.",
"hint": "Über den Garten stufenlos erreichbar.",
"points": "2.6,21.8 8.2,21.8 8.2,56.0 2.6,56.0",
"photo_ids": [
21
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "wohnen",
"name": "Wohnbereich",
"description": "Helles Wohnzimmer mit Fensterfront zur Terrasse. Das Schrankbett bietet Platz für eine dritte Person.",
"hint": null,
"points": "10.4,21.8 49.5,21.8 49.5,40.3 30.4,40.3 30.4,64.4 15.3,64.4 9.3,52.0 10.4,47.9",
"photo_ids": [
2,
1,
6
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "kueche",
"name": "Küche & Essplatz",
"description": "Einbauküche zum Selbstversorgen mit Essplatz für vier.",
"hint": null,
"points": "30.4,40.3 49.5,40.3 49.5,64.4 30.4,64.4",
"photo_ids": [
9,
8
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "diele",
"name": "Diele",
"description": "Großer Einbauschrank. Von hier geht es zu Bad, Schlafzimmer und Eingang.",
"hint": null,
"points": "49.6,21.8 69.8,21.8 73.9,28.5 70.1,37.5 66.6,43.5 66.6,41.1 49.6,41.1",
"photo_ids": [
11
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "eingang",
"name": "Eingangsbereich",
"description": "Eigene Wohnungstür mit Fußabtreter.",
"hint": "Eingang im Erdgeschoss mit einer Stufe.",
"points": "75.9,8.9 88.5,8.9 88.5,28.8 74.2,28.8 70.7,22.3 70.7,16.3",
"photo_ids": [],
"amenity_ids": [],
"is_visible": true
},
{
"id": "bad",
"name": "Bad",
"description": "Bad mit Glasdusche (90 × 90 cm) und beleuchtetem Spiegelschrank.",
"hint": "Flache Dusche mit kleiner Kante – die Wohnung ist nicht rollstuhlgerecht.",
"points": "49.8,41.3 66.3,41.3 66.3,64.7 49.8,64.7",
"photo_ids": [
16,
17
],
"amenity_ids": [],
"is_visible": true
},
{
"id": "schlafen",
"name": "Schlafzimmer",
"description": "Ruhiges Schlafzimmer zur Gartenseite mit Kingsize-Bett.",
"hint": null,
"points": "74.5,29.2 89.3,29.2 89.3,65.9 66.6,65.9 66.6,43.5 70.6,37.5",
"photo_ids": [
13,
14
],
"amenity_ids": [],
"is_visible": true
}
]
+123
View File
@@ -0,0 +1,123 @@
<?php
namespace Tests\Feature;
use App\Enums\UserRole;
use App\Filament\Resources\FloorPlans\FloorPlanResource;
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
use App\Models\Amenity;
use App\Models\FloorPlan;
use App\Models\Page;
use App\Models\Photo;
use App\Models\Property;
use App\Models\Site;
use App\Models\User;
use Carbon\CarbonImmutable;
use Database\Seeders\PropertySeeder;
use Database\Seeders\SiteSeeder;
use Database\Seeders\WebsiteContentSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\TestCase;
class FloorPlanTest extends TestCase
{
use RefreshDatabase;
private Property $property;
protected function setUp(): void
{
parent::setUp();
$this->travelTo(CarbonImmutable::parse('2026-10-22 10:00'));
$this->seed([PropertySeeder::class, WebsiteContentSeeder::class, SiteSeeder::class]);
$this->withoutVite();
$this->property = Property::sole();
}
public function test_floor_plan_belongs_to_the_landlord_of_its_apartment(): void
{
$plan = FloorPlan::factory()->for($this->property)->create();
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
$this->assertTrue($this->property->floorPlan->is($plan));
}
public function test_area_points_are_parsed_in_percent_and_invalid_pairs_are_dropped(): void
{
$this->assertSame([[10.0, 20.5], [50.0, 20.5], [50.0, 65.0]], FloorPlan::points(' 10,20.5 50,20.5 50,65 abc 150,3 '));
$this->assertSame([], FloorPlan::points(null));
}
public function test_section_shows_visible_rooms_with_area_photo_equipment_and_hint(): void
{
$roomPhoto = Photo::factory()->create(['alt_text' => 'Glasdusche im Bad']);
$shower = Amenity::factory()->for($this->property)->create(['name' => 'Dusche mit niedrigem Einstieg']);
FloorPlan::factory()->for($this->property)->create([
'photo_id' => Photo::factory()->create(['alt_text' => 'Grundriss der Wohnung'])->id,
'rooms' => [
['id' => 'a', 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65', 'photo_ids' => [$roomPhoto->id], 'amenity_ids' => [$shower->id], 'is_visible' => true],
['id' => 'b', 'name' => 'Abstellkammer', 'points' => '1,1 2,1 2,2', 'is_visible' => false],
['id' => 'c', 'name' => 'Ohne Fläche', 'points' => '1,1 2,2', 'is_visible' => true],
],
]);
$this->placeSectionOnApartmentPage();
$this->get('/wohnung')
->assertOk()
->assertSee('Der Grundriss')
->assertSee('points="50,40 66,40 66,65"', false)
->assertSee('id="raum-bad-1"', false)
->assertSee('Bad mit Glasdusche.')
->assertSee('Flache Dusche mit kleiner Kante.')
->assertSee('Dusche mit niedrigem Einstieg')
->assertSee('Glasdusche im Bad')
->assertDontSee('Abstellkammer')
->assertDontSee('Ohne Fläche');
}
public function test_section_shows_nothing_without_a_floor_plan(): void
{
$this->placeSectionOnApartmentPage();
$this->get('/wohnung')->assertOk()->assertDontSee('Der Grundriss');
}
public function test_content_editor_creates_a_floor_plan_and_a_room_needs_an_area(): void
{
$this->actingAs(User::factory()->role(UserRole::Content)->create());
$planPhoto = Photo::factory()->create();
$this->get(FloorPlanResource::getUrl('index'))->assertOk();
Livewire::test(CreateFloorPlan::class)
->fillForm([
'property_id' => $this->property->id,
'photo_id' => $planPhoto->id,
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10', 'is_visible' => true]],
])
->call('create')
->assertHasFormErrors(['rooms.diele.points']);
Livewire::test(CreateFloorPlan::class)
->fillForm([
'property_id' => $this->property->id,
'photo_id' => $planPhoto->id,
'rooms' => ['diele' => ['id' => 'x', 'name' => 'Diele', 'points' => '10,10 20,10 20,30 10,30', 'is_visible' => true]],
])
->call('create')
->assertHasNoFormErrors();
$plan = FloorPlan::sole();
$this->assertSame($this->property->tenant_id, $plan->tenant_id);
$this->assertSame(['Diele'], $plan->visibleRooms()->pluck('name')->all());
}
private function placeSectionOnApartmentPage(): void
{
$page = Site::sole()->pages()->where('slug', 'wohnung')->sole();
$page->update(['sections' => [...$page->sections, ['type' => 'floor_plan', 'data' => ['heading' => 'Der Grundriss']]]]);
$this->assertInstanceOf(Page::class, $page);
}
}
@@ -3,6 +3,7 @@
namespace Tests\Feature;
use App\Enums\ReviewStatus;
use App\Models\FloorPlan;
use App\Models\Page;
use App\Models\Property;
use App\Models\Review;
@@ -38,6 +39,10 @@ protected function setUp(): void
Review::factory()->for($property)->count(2)->create(['status' => ReviewStatus::Approved]);
SpecialOffer::factory()->for($property)->create(['name' => 'Herbstwochen', 'is_featured' => true]);
SpecialOffer::factory()->for($property)->create(['name' => 'Ab 5 Nächten', 'min_nights' => 5]);
FloorPlan::factory()->for($property)->create();
$apartment = Page::query()->where('slug', 'wohnung')->sole();
$apartment->update(['sections' => [...$apartment->sections, ['type' => 'floor_plan', 'data' => ['heading' => 'Der Grundriss']]]]);
}
public function test_every_installed_theme_renders_all_pages_with_offers_in_every_display_mode(): void
@@ -60,6 +65,8 @@ public function test_every_installed_theme_renders_all_pages_with_offers_in_ever
foreach (self::PAGES as $path) {
$this->get($path)->assertOk();
}
$this->get('/wohnung')->assertSee('Der Grundriss')->assertSee('Wohnbereich');
}
}
}
+37
View File
@@ -8,6 +8,7 @@
use App\Filament\Resources\Amenities\AmenityResource;
use App\Filament\Resources\Faqs\FaqResource;
use App\Filament\Resources\Notices\NoticeResource;
use App\Filament\Resources\Photos\Pages\CreatePhoto;
use App\Filament\Resources\Photos\Pages\ListPhotos;
use App\Filament\Resources\Photos\PhotoResource;
use App\Filament\Resources\Properties\PropertyResource;
@@ -87,6 +88,42 @@ public function test_several_photos_are_uploaded_at_once(): void
$this->assertSame(['Wohn zimmer', 'Kueche'], Photo::orderBy('sort_order')->pluck('alt_text')->all());
}
public function test_photo_uploaded_in_the_admin_is_stored_on_the_public_disk(): void
{
Storage::fake('local');
Livewire::test(CreatePhoto::class)
->fillForm([
'image' => [UploadedFile::fake()->image('grundriss.png', 1600, 900)],
'alt_text' => 'Grundriss mit Teppichen',
'category' => PhotoCategory::Apartment,
])
->call('create')
->assertHasNoFormErrors();
$media = Photo::query()->where('alt_text', 'Grundriss mit Teppichen')->sole()->getFirstMedia(Photo::COLLECTION);
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/'.$media->file_name);
$this->assertSame([], Storage::disk('local')->allFiles());
}
public function test_migration_moves_photos_from_the_private_disk_to_the_public_disk(): void
{
Storage::fake('local');
$photo = Photo::factory()->create();
$media = $photo->addMedia(UploadedFile::fake()->image('alt.jpg', 1200, 800))->toMediaCollection(Photo::COLLECTION, 'local');
Storage::disk('local')->assertExists($media->id.'/alt.jpg');
(require database_path('migrations/2026_10_23_171001_move_photo_media_to_the_public_disk.php'))->up();
$media->refresh();
$this->assertSame(['public', 'public'], [$media->disk, $media->conversions_disk]);
Storage::disk('public')->assertExists($media->id.'/alt.jpg');
Storage::disk('public')->assertExists($media->id.'/conversions/alt-lg.webp');
Storage::disk('local')->assertMissing($media->id.'/alt.jpg');
$this->assertStringEndsWith('/conversions/alt-lg.webp', $photo->fresh()->url('lg'));
}
public function test_notices_are_visible_only_within_their_dates(): void
{
$this->travelTo(CarbonImmutable::parse('2026-11-10'));