Files
fewo-stommer/app/Pricing/AdvertisedOffer.php
Lars StommerandClaude Opus 5.5 7d0bc93abc Offers by their own rules, seasonal photos per section, theme authoring tooling
- Special offers: kinds (rule, fixed dates, gap filler), package price, priority, highlight;
  GapFinder detects calendar gaps (optionally waiving the minimum stay); OfferShowcase decides
  what the website advertises and prices fixed dates/gaps with PriceCalculator; offers section
  shows them side by side, as a list or rotating; hero can show the top offer. Appearances no
  longer carry a featured offer.
- Sections get stable ids; appearances set photos per section ("Bilder je Baustein") and
  sections can be limited to appearances. Photo pickers show thumbnails everywhere.
- Themes: themes:make (scaffold, never overwrites), themes:check (contract, build, markup,
  colours, external resources, WCAG contrast), themes:preview (signed links per page and
  appearance), signed ?theme= preview and preview action in the site form, inherited colour
  tokens in the admin. Base CSS split into theme.css + reusable theme-base.css.
- docs/THEME-ERSTELLUNG.md: binding guide for building additional themes elsewhere.

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

59 lines
1.6 KiB
PHP
Raw Permalink 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\Pricing;
use App\Models\SpecialOffer;
use Carbon\CarbonImmutable;
/**
* An offer as the website shows it: for fixed dates and gap fillers with concrete dates and an example price.
*/
final readonly class AdvertisedOffer
{
/**
* @param list<string> $conditions
*/
public function __construct(
public SpecialOffer $offer,
public string $title,
public ?string $description,
public string $advantage,
public array $conditions,
public ?CarbonImmutable $arrival = null,
public ?CarbonImmutable $departure = null,
public ?PriceQuote $quote = null,
) {}
public function nights(): ?int
{
return $this->arrival && $this->departure ? (int) $this->arrival->diffInDays($this->departure) : null;
}
/**
* Price before the discount (accommodation, extra guests, cleaning) – for "statt …".
*/
public function regularTotal(): ?int
{
return $this->quote ? $this->quote->total() + $this->quote->discount() : null;
}
/**
* Link to the booking page, with the dates filled in when the offer has concrete dates.
*/
public function bookingUrl(): string
{
return route('booking.create', array_filter([
'anreise' => $this->arrival?->toDateString(),
'abreise' => $this->departure?->toDateString(),
]));
}
/**
* Stable key for the view (an offer can appear several times with different gaps).
*/
public function key(): string
{
return $this->offer->id.'-'.($this->arrival?->toDateString() ?? 'rule');
}
}