Files
fewo-stommer/app/Http/Controllers/PageController.php
Lars StommerandClaude Opus 5.5 4f69b426a4 Booking path 1 (offer + guest acceptance), 2FA for all, privacy hardening, brand graphics in theme
- Offer workflow: "Angebot senden" in the admin (dates, guests, promo code, manual price adjustment,
  validity from the property's hold time, message, guest data for the contract) with live price;
  contract draft PDF; signed, versioned offer page for the guest to accept (acceptance record without
  IP) or decline; expiry job, landlord notifications, editable offer texts, wording on the website.
- 2FA is mandatory for every admin account.
- Privacy: complete anonymisation (notes, attribution, review names, offer messages), shorter
  periods for unbinding requests, portal mail excerpts and attribution (configurable proposals),
  iCal summary not stored, known e-mail no longer overwrites guest data, security headers, bearer
  tokens for automations, metadata stripped from photo originals, review link throttled.
- Daily database backup (backup:database) and scripts/backup-pull.sh for the NAS.
- Theme: brand mark in header/footer, favicon/touch icon, wave divider, icons, illustration as
  image placeholder; navy follows the text colour for dark appearances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 21:38:22 +02:00

99 lines
3.3 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Page;
use App\Support\Content;
use App\Themes\SectionRegistry;
use App\Themes\Theme;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Response;
/**
* Renders the website pages of the current site with the active theme.
*/
class PageController extends Controller
{
public function __construct(private SectionRegistry $sections) {}
/**
* Resolved per call: the controller is built before the middleware has determined site and appearance.
*/
private function theme(): Theme
{
return app(Theme::class);
}
public function home(): View
{
return $this->show(Page::HOME);
}
public function show(string $slug): View
{
abort_unless($this->theme()->site->exists, 404);
$page = $this->theme()->site->pages()
->where('slug', $slug)
->where('is_published', true)
->firstOrFail();
return view('theme::page', [
'page' => $page,
'sections' => $this->sections->render($this->theme(), $page->sections),
'title' => $page->isHome() ? null : ($page->seo_title ?: $page->title),
'description' => $page->seo_description ?: ($page->isHome() ? Content::get('seo.home.description') : null),
'ogImage' => $this->theme()->heroPhoto()?->url('lg') ?: null,
'structuredData' => $page->isHome() ? $this->structuredData() : null,
]);
}
public function sitemap(): Response
{
$pages = $this->theme()->site->exists
? $this->theme()->site->pages()->where('is_published', true)->get()
: collect();
return response()->view('sitemap', ['pages' => $pages], 200, ['Content-Type' => 'application/xml']);
}
public function robots(): Response
{
return response(implode("\n", [
'User-agent: *',
'Disallow: /admin',
'Disallow: /livewire',
'Disallow: /automation',
'Disallow: /bewertung',
'Disallow: /angebote',
'Disallow: /angebot/',
'Sitemap: '.route('sitemap'),
'',
]), 200, ['Content-Type' => 'text/plain; charset=UTF-8']);
}
/**
* schema.org data of the property for search engines.
*
* @return array<string, mixed>|null
*/
private function structuredData(): ?array
{
$property = $this->theme()->property();
if ($property === null) {
return null;
}
return array_filter([
'@context' => 'https://schema.org',
'@type' => 'VacationRental',
'name' => $property->name,
'url' => route('home'),
'image' => $this->theme()->heroPhoto()?->url('lg') ?: null,
'address' => ['@type' => 'PostalAddress', 'streetAddress' => str($property->address)->before(',')->trim()->toString(), 'addressLocality' => 'Kühlungsborn', 'postalCode' => '18225', 'addressCountry' => 'DE'],
'containsPlace' => ['@type' => 'Accommodation', 'floorSize' => ['@type' => 'QuantitativeValue', 'value' => $property->size_sqm, 'unitCode' => 'MTK'], 'occupancy' => ['@type' => 'QuantitativeValue', 'maxValue' => $property->max_guests]],
'telephone' => config('fewo.owner.phone'),
]);
}
}