Phase 1: Wohnungen, Saisons & Preisberechnung

- Datenmodell Property/Season/Extra (Beträge in Cent), Seeder mit Preisliste 2026
- PriceCalculator: Saison-Splitting, Mindestaufenthalt, Zusatzperson, Endreinigung, Extras, Anzahlung/Restzahlung
- Filament-Verwaltung: Wohnungen, Saisons (Überschneidungsprüfung, Lückenwarnung, Kopie ins Folgejahr, Preisrechner), Zusatzleistungen
- Tests für Preisberechnung und Saisonverwaltung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 09:19:49 +02:00
1 parent bf4c1c0838
commit 2e9a391b37
35 files changed
+1766 -12

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
<?php
namespace App\Models;
use Carbon\CarbonInterface;
use Database\Factories\SeasonFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A pricing period. A night belongs to the season when starts_on <= night < ends_on,
* so consecutive seasons share their boundary date (e.g. 03.01.–07.03. and 07.03.–03.04.).
*/
#[Fillable(['property_id', 'name', 'starts_on', 'ends_on', 'nightly_rate', 'min_nights'])]
class Season extends Model
{
/** @use HasFactory<SeasonFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'starts_on' => 'immutable_date',
'ends_on' => 'immutable_date',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* Seasons that share at least one night with the half-open period [$from, $until).
*
* @param Builder<Season> $query
* @return Builder<Season>
*/
#[Scope]
protected function overlapping(Builder $query, CarbonInterface $from, CarbonInterface $until): Builder
{
return $query
->whereDate('starts_on', '<', $until)
->whereDate('ends_on', '>', $from);
}
public function containsNight(CarbonInterface $night): bool
{
return $this->starts_on->lessThanOrEqualTo($night) && $this->ends_on->greaterThan($night);
}
}