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>
169 lines
4.0 KiB
PHP
169 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\Concerns\BelongsToTenant;
|
|
use Carbon\CarbonImmutable;
|
|
use Database\Factories\PropertyFactory;
|
|
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\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
/**
|
|
* A rentable holiday apartment. All money amounts are stored in euro cents.
|
|
*/
|
|
#[Fillable([
|
|
'site_id',
|
|
'name',
|
|
'slug',
|
|
'image_world',
|
|
'address',
|
|
'size_sqm',
|
|
'max_guests',
|
|
'included_guests',
|
|
'extra_guest_fee_per_night',
|
|
'cleaning_fee',
|
|
'deposit_percent',
|
|
'balance_due_days_before_arrival',
|
|
'hold_hours',
|
|
'check_in_time',
|
|
'check_out_time',
|
|
'changeover_weekday',
|
|
'min_stay_fill_gaps',
|
|
'min_stay_until_changeover',
|
|
'min_stay_absolute',
|
|
'is_active',
|
|
])]
|
|
class Property extends Model
|
|
{
|
|
/** @use HasFactory<PropertyFactory> */
|
|
use BelongsToTenant, HasFactory;
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
/**
|
|
* Defaults of the minimum stay rules (as in the migration), also before the model is reloaded.
|
|
*
|
|
* @var array<string, mixed>
|
|
*/
|
|
protected $attributes = [
|
|
'min_stay_fill_gaps' => true,
|
|
'min_stay_until_changeover' => false,
|
|
'min_stay_absolute' => 2,
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_active' => 'boolean',
|
|
'min_stay_fill_gaps' => 'boolean',
|
|
'min_stay_until_changeover' => 'boolean',
|
|
'changeover_weekday' => 'integer',
|
|
'min_stay_absolute' => 'integer',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Season, $this>
|
|
*/
|
|
/**
|
|
* @return BelongsTo<Site, $this>
|
|
*/
|
|
public function site(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Site::class);
|
|
}
|
|
|
|
public function seasons(): HasMany
|
|
{
|
|
return $this->hasMany(Season::class)->orderBy('starts_on');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Booking, $this>
|
|
*/
|
|
public function bookings(): HasMany
|
|
{
|
|
return $this->hasMany(Booking::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<BlockedPeriod, $this>
|
|
*/
|
|
public function blockedPeriods(): HasMany
|
|
{
|
|
return $this->hasMany(BlockedPeriod::class)->orderBy('starts_on');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Channel, $this>
|
|
*/
|
|
public function channels(): HasMany
|
|
{
|
|
return $this->hasMany(Channel::class);
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Amenity, $this>
|
|
*/
|
|
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>
|
|
*/
|
|
public function specialOffers(): HasMany
|
|
{
|
|
return $this->hasMany(SpecialOffer::class);
|
|
}
|
|
|
|
/**
|
|
* Periods within [$from, $until) for which no season defines a price.
|
|
*
|
|
* @return list<array{from: CarbonImmutable, until: CarbonImmutable}>
|
|
*/
|
|
public function uncoveredPeriods(CarbonImmutable $from, CarbonImmutable $until): array
|
|
{
|
|
$gaps = [];
|
|
$cursor = $from;
|
|
|
|
foreach ($this->seasons()->overlapping($from, $until)->get() as $season) {
|
|
if ($season->starts_on->greaterThan($cursor)) {
|
|
$gaps[] = ['from' => $cursor, 'until' => $season->starts_on];
|
|
}
|
|
|
|
$cursor = $cursor->max($season->ends_on);
|
|
}
|
|
|
|
if ($cursor->lessThan($until)) {
|
|
$gaps[] = ['from' => $cursor, 'until' => $until];
|
|
}
|
|
|
|
return $gaps;
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<Extra, $this>
|
|
*/
|
|
public function extras(): HasMany
|
|
{
|
|
return $this->hasMany(Extra::class)->orderBy('sort_order');
|
|
}
|
|
}
|