Files
fewo-stommer/app/Themes/Sections/FloorPlanSection.php
T
LarsandClaude Opus 5.5 f7cbc66451
Deploy / test (push) Failing after 2s
Deploy / deploy (push) Skipped
Section "Grundriss (interaktiv)": floor plan with rooms, admin editor, Seebad view
- 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

72 lines
2.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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(),
]),
];
}
}