Prices & offers page (seasons, special offers/promo codes, extras) and photos in the simple admin mode

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 22:19:08 +02:00
1 parent 7a6ee316cd
commit fd744edf8c
4 files changed
+114 -3

No files matched your search

+88
View File
@@ -0,0 +1,88 @@
<?php
namespace App\Filament\Pages;
use App\Enums\UserRole;
use App\Filament\Concerns\FollowsAdminMode;
use App\Filament\Resources\Properties\Pages\EditProperty;
use App\Filament\Resources\Properties\RelationManagers\ExtrasRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SpecialOffersRelationManager;
use App\Models\Property;
use BackedEnum;
use Filament\Forms\Components\Select;
use Filament\Pages\Page;
use Filament\Schemas\Components\Livewire;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Components\Text;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Livewire\Attributes\Url;
use UnitEnum;
/**
* The yearly price work in one place, without the other apartment settings: seasons & prices,
* special offers & promo codes, extras. Reuses the relation managers of the apartment.
*/
class PricesAndOffers extends Page
{
use FollowsAdminMode;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCurrencyEuro;
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
protected static ?string $navigationLabel = 'Preise & Angebote';
protected static ?string $title = 'Preise & Angebote';
protected static ?string $slug = 'preise-und-angebote';
protected static ?int $navigationSort = 3;
#[Url(as: 'wohnung')]
public ?int $propertyId = null;
public static function canAccess(): bool
{
return (bool) auth()->user()?->hasRole(UserRole::Admin, UserRole::Rentals);
}
public function mount(): void
{
$this->propertyId ??= Property::query()->where('is_active', true)->value('id') ?? Property::query()->value('id');
}
public function content(Schema $schema): Schema
{
$property = Property::find($this->propertyId);
if ($property === null) {
return $schema->components([Text::make('Es ist noch keine Wohnung angelegt (Expertenansicht › Wohnungen).')]);
}
$context = ['ownerRecord' => $property, 'pageClass' => EditProperty::class];
return $schema->components([
Select::make('propertyId')
->label('Wohnung')
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
->live()
->afterStateUpdated(fn () => $this->redirect(static::getUrl(['wohnung' => $this->propertyId])))
->visible(fn (): bool => Property::query()->count() > 1),
Tabs::make('prices')
->persistTabInQueryString()
->tabs([
Tab::make('Saisons & Preise')->icon(Heroicon::OutlinedCalendar)->schema([
Livewire::make(SeasonsRelationManager::class, $context)->key("seasons-{$property->id}"),
]),
Tab::make('Sonderangebote & Rabattcodes')->icon(Heroicon::OutlinedSparkles)->schema([
Livewire::make(SpecialOffersRelationManager::class, $context)->key("offers-{$property->id}"),
]),
Tab::make('Extras')->icon(Heroicon::OutlinedGift)->schema([
Livewire::make(ExtrasRelationManager::class, $context)->key("extras-{$property->id}"),
]),
]),
]);
}
}