Die Theme-Sitzung wartete darauf: Seebad ruft schon ortsneutrale Plätze über `partials/motif` auf und behilft sich mit einem eigenen `motifs/`- Ordner. Der Kommentar dort sagt es selbst – „so a later picture-world system can replace the mapping below". Das System gibt es jetzt. **Bildwelten** (A18–A20) sind Pakete wie Themes: `resources/image-worlds/ <key>/` mit `world.json` und `svg/`. Eine Website wählt eine Bildwelt, eine Wohnung darf eine andere tragen – das ist der Platz für die Bergwohnung auf einer Küsten-Website. Vorlagen fragen über `$theme->motif($slot)` nach einem Platz, nie nach einer Datei. Die Render-Logik ist aus Seebads Partial in die Anwendung gewandert, damit jedes Theme sie bekommt: Inline-SVG (nimmt die Textfarbe an, kein zweiter Request), Titel und ARIA entfernt, und die internen Ids je Aufruf eindeutig gemacht – zwei Kopien derselben Grafik auf einer Seite würden sonst auf denselben Verlauf zeigen und eine davon verlöre ihre Farben. Ein leerer Platz ist kein Fehler: die Vorlage bekommt schlicht keine Dekoration. Weil das leicht zu übersehen ist, meldet `php artisan image-worlds:check`, welcher Platz ohne Datei dasteht. **Marke je Website** (A14/A22): Logo, Favicon und ein Logo für E-Mail und Vertrag als Medien der Website. Der Mietvertrag bettet die Datei ein statt eine URL zu holen – er wird auf dem Server gerendert und darf nicht davon abhängen, dass dieser sich selbst erreicht. Ohne Logo bleibt der Vertrag wie bisher. `resources/themes/**` ist unberührt: die Ostsee-Grafiken sind kopiert, nicht verschoben. Was die Theme-Sitzung nun tun kann, steht in ZUSAMMENARBEIT.md §6; ihr Wunsch aus §5 ist als erledigt vermerkt. 272 Feature-Tests grün. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Documents;
|
|
|
|
use App\Models\Booking;
|
|
use App\Models\Site;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
/**
|
|
* The rental contract as PDF. As a draft it is part of the offer (offer_path, one file per offer version);
|
|
* the final contract is generated at confirmation (contract_path). Both are stored, so later changes of
|
|
* texts or prices do not alter a document the guest already received.
|
|
*/
|
|
class RentalContract
|
|
{
|
|
private const DISK = 'local';
|
|
|
|
public function generate(Booking $booking, bool $draft = false): string
|
|
{
|
|
$booking->loadMissing(['guest', 'property']);
|
|
$path = $draft
|
|
? "contracts/Angebot-{$booking->reference}-v{$booking->offer_version}.pdf"
|
|
: "contracts/Mietvertrag-{$booking->reference}.pdf";
|
|
|
|
// The logo is embedded as a file: the PDF is rendered on the server and must not depend on
|
|
// fetching anything over the network. Each website has its own (A14).
|
|
$logo = $booking->website()?->brandPath(Site::BRAND_DOCUMENT_LOGO);
|
|
|
|
Storage::disk(self::DISK)->put($path, Pdf::loadView('pdf.contract', [
|
|
'booking' => $booking,
|
|
'draft' => $draft,
|
|
'logo' => $logo,
|
|
])->setPaper('a4')->output());
|
|
$booking->update([$draft ? 'offer_path' : 'contract_path' => $path]);
|
|
|
|
return $path;
|
|
}
|
|
|
|
public function absolutePath(Booking $booking, bool $draft = false): ?string
|
|
{
|
|
$path = $draft ? $booking->offer_path : $booking->contract_path;
|
|
|
|
return $path && Storage::disk(self::DISK)->exists($path) ? Storage::disk(self::DISK)->path($path) : null;
|
|
}
|
|
}
|