Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12e4079126 | ||
|
|
1871c04507 | ||
|
|
dfd3f77a5d | ||
|
|
f7cbc66451 | ||
|
|
04b5189bd8 | ||
|
|
9b8a851ce9 | ||
|
|
b3114cdfe3 | ||
|
|
faf2133232 | ||
|
|
d2f53ceb84 | ||
|
|
ab1dffc72f | ||
|
|
fc61369c4a | ||
|
|
cec49da1be | ||
|
|
8ebc1a3878 | ||
|
|
d9e52c4789 | ||
|
|
3621f7e924 | ||
|
|
6930d3ab0f | ||
|
|
c215da0590 | ||
|
|
e49f160496 | ||
|
|
bc2b175556 | ||
|
|
5416b37dfc | ||
|
|
30e9aa7b26 | ||
|
|
4951f227f1 | ||
|
|
a9ad4dbf0b | ||
|
|
e276cd0548 |
No files matched your search
@@ -14,6 +14,8 @@
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Tenancy\TenantContextMissing;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
@@ -38,6 +40,24 @@ public function __construct(
|
||||
* @throws ReservationException
|
||||
*/
|
||||
public function handle(Property $property, StayRequest $stay, array $guestData, ?string $message = null, string $source = 'website', bool $sendMails = true, array $attribution = []): Booking
|
||||
{
|
||||
$tenant = $property->tenant;
|
||||
|
||||
if ($tenant === null) {
|
||||
throw new TenantContextMissing(Property::class);
|
||||
}
|
||||
|
||||
return app(TenantContext::class)->run(
|
||||
$tenant,
|
||||
fn (): Booking => $this->create($property, $stay, $guestData, $message, $source, $sendMails, $attribution),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{first_name: string, last_name: string, email: string, phone?: ?string, street?: ?string, postal_code?: ?string, city?: ?string, country?: ?string} $guestData
|
||||
* @param array{referral_source?: ?string, utm_source?: ?string, utm_medium?: ?string, utm_campaign?: ?string} $attribution
|
||||
*/
|
||||
private function create(Property $property, StayRequest $stay, array $guestData, ?string $message, string $source, bool $sendMails, array $attribution): Booking
|
||||
{
|
||||
$booking = DB::transaction(function () use ($property, $stay, $guestData, $message, $source, $attribution): Booking {
|
||||
Property::whereKey($property->getKey())->lockForUpdate()->first();
|
||||
@@ -91,7 +111,11 @@ private function guestFor(array $guestData): array
|
||||
$guest = Guest::query()->where('email', $email)->first();
|
||||
|
||||
if ($guest === null) {
|
||||
return [Guest::create([...$guestData, 'email' => $email]), []];
|
||||
return [Guest::create([
|
||||
...$guestData,
|
||||
'email' => $email,
|
||||
'tenant_id' => app(TenantContext::class)->id(),
|
||||
]), []];
|
||||
}
|
||||
|
||||
$labels = ['first_name' => 'Vorname', 'last_name' => 'Nachname', 'phone' => 'Telefon', 'street' => 'Straße', 'postal_code' => 'PLZ', 'city' => 'Ort', 'country' => 'Land'];
|
||||
|
||||
@@ -98,7 +98,10 @@ public function handle(Booking $booking, array $changes = [], bool $sendMail = t
|
||||
*/
|
||||
public function offerUrl(Booking $booking): string
|
||||
{
|
||||
return URL::temporarySignedRoute('offers.show', $booking->hold_expires_at, ['booking' => $booking, 'v' => $booking->offer_version]);
|
||||
$parameters = ['booking' => $booking, 'v' => $booking->offer_version];
|
||||
|
||||
return $booking->website()?->temporarySignedRoute('offers.show', $booking->hold_expires_at, $parameters)
|
||||
?? URL::temporarySignedRoute('offers.show', $booking->hold_expires_at, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
@@ -13,7 +15,7 @@
|
||||
use function Laravel\Prompts\select;
|
||||
use function Laravel\Prompts\text;
|
||||
|
||||
#[Signature('users:create {email? : E-Mail-Adresse} {--name= : Name} {--role= : admin, rentals oder content}')]
|
||||
#[Signature('users:create {email? : E-Mail-Adresse} {--name= : Name} {--role= : admin, rentals oder content} {--tenant= : Kurzname des Mandanten}')]
|
||||
#[Description('Create an admin panel account (the password is entered interactively and never passed as an argument)')]
|
||||
class CreateUser extends Command
|
||||
{
|
||||
@@ -22,6 +24,12 @@ class CreateUser extends Command
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$tenant = $this->resolveTenant();
|
||||
|
||||
if ($tenant === false) {
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$email = $this->argument('email') ?? text('E-Mail-Adresse', required: true, validate: ['email' => 'email']);
|
||||
$email = mb_strtolower(trim($email));
|
||||
|
||||
@@ -51,7 +59,12 @@ public function handle(): int
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
User::create(['name' => $name, 'email' => $email, 'role' => $role, 'password' => $password]);
|
||||
$user = User::create(['name' => $name, 'email' => $email, 'role' => $role, 'password' => $password]);
|
||||
|
||||
if ($tenant instanceof Tenant) {
|
||||
app(TenantContext::class)->set($tenant);
|
||||
$user->attachCurrentRole($tenant);
|
||||
}
|
||||
|
||||
$this->info("Benutzer {$email} ({$role->getLabel()}) angelegt.");
|
||||
|
||||
@@ -59,4 +72,35 @@ public function handle(): int
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* One landlord is used automatically. Several landlords need --tenant. None is allowed:
|
||||
* the account exists and is attached later.
|
||||
*/
|
||||
private function resolveTenant(): Tenant|false|null
|
||||
{
|
||||
$slug = $this->option('tenant');
|
||||
|
||||
if (is_string($slug) && $slug !== '') {
|
||||
$tenant = Tenant::query()->where('slug', $slug)->first();
|
||||
|
||||
if ($tenant === null) {
|
||||
$this->error("Kein Mandant mit dem Kurznamen {$slug}.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $tenant;
|
||||
}
|
||||
|
||||
$count = Tenant::query()->count();
|
||||
|
||||
if ($count > 1) {
|
||||
$this->error('Es gibt mehrere Mandanten. Bitte --tenant=kurzname angeben.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $count === 1 ? Tenant::query()->first() : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Attributes\Description;
|
||||
use Illuminate\Console\Attributes\Signature;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
#[Signature('users:promote-operator {email : E-Mail-Adresse}')]
|
||||
#[Description('Grant the operator flag. The account keeps its password, two-factor setup and any landlord role.')]
|
||||
class PromoteOperator extends Command
|
||||
{
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$email = mb_strtolower(trim((string) $this->argument('email')));
|
||||
$user = User::query()->where('email', $email)->first();
|
||||
|
||||
if ($user === null) {
|
||||
$this->error('Kein Benutzer mit dieser E-Mail.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$user->forceFill(['is_operator' => true])->save();
|
||||
|
||||
$this->info("{$email} ist jetzt Betreiber. Eine bestehende Mandanten-Rolle bleibt.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
/**
|
||||
* What a role may do inside the current landlord. A new role is a new case on UserRole plus a list here.
|
||||
*/
|
||||
enum Permission: string
|
||||
{
|
||||
case Bookings = 'bookings';
|
||||
case Properties = 'properties';
|
||||
case Guests = 'guests';
|
||||
case Reviews = 'reviews';
|
||||
case Channels = 'channels';
|
||||
case Content = 'content';
|
||||
case Users = 'users';
|
||||
case Settings = 'settings';
|
||||
}
|
||||
+30
-2
@@ -14,7 +14,7 @@ enum UserRole: string implements HasDescription, HasLabel
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Admin => 'Administrator',
|
||||
self::Admin => 'Mandanten-Administrator',
|
||||
self::Rentals => 'Vermietung',
|
||||
self::Content => 'Inhalte',
|
||||
};
|
||||
@@ -23,9 +23,37 @@ public function getLabel(): string
|
||||
public function getDescription(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Admin => 'Alles, inklusive Benutzerverwaltung',
|
||||
self::Admin => 'Alles im eigenen Mandanten, inklusive Benutzerverwaltung',
|
||||
self::Rentals => 'Buchungen, Gäste, Preise, Angebote und Bewertungen',
|
||||
self::Content => 'Bilder, Texte, FAQ, Hinweise und Bewertungen',
|
||||
};
|
||||
}
|
||||
|
||||
public function grants(Permission $permission): bool
|
||||
{
|
||||
return in_array($permission, $this->permissions(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Abilities inside the current landlord. The operator is not a role here.
|
||||
*
|
||||
* @return list<Permission>
|
||||
*/
|
||||
public function permissions(): array
|
||||
{
|
||||
return match ($this) {
|
||||
self::Admin => Permission::cases(),
|
||||
self::Rentals => [
|
||||
Permission::Bookings,
|
||||
Permission::Properties,
|
||||
Permission::Guests,
|
||||
Permission::Reviews,
|
||||
Permission::Channels,
|
||||
],
|
||||
self::Content => [
|
||||
Permission::Content,
|
||||
Permission::Reviews,
|
||||
],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator;
|
||||
|
||||
use App\Filament\Operator\Tenants\Pages\CreateTenant;
|
||||
use App\Filament\Operator\Tenants\Pages\EditTenant;
|
||||
use App\Filament\Operator\Tenants\Pages\ListTenants;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\TenantAccessLog;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TenantResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Tenant::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBuildingOffice;
|
||||
|
||||
protected static ?string $modelLabel = 'Mandant';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Mandanten';
|
||||
|
||||
protected static ?string $navigationLabel = 'Mandanten';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label('Name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
TextInput::make('slug')
|
||||
->label('Kurzname')
|
||||
->required()
|
||||
->alphaDash()
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(255),
|
||||
Toggle::make('is_active')
|
||||
->label('Aktiv')
|
||||
->helperText('Ein gesperrter Mandant ist von außen nicht mehr erreichbar. Der Betreiber kommt weiter hinein.')
|
||||
->default(true),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('slug')->label('Kurzname'),
|
||||
ToggleColumn::make('is_active')->label('Aktiv'),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
Action::make('openAdmin')
|
||||
->label('Im Admin öffnen')
|
||||
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
|
||||
->action(function (Tenant $record) {
|
||||
TenantAccessLog::query()->create([
|
||||
'tenant_id' => $record->id,
|
||||
'user_id' => auth()->id(),
|
||||
]);
|
||||
|
||||
$domain = $record->sites()->withoutGlobalScope('tenant')->whereNotNull('domain')->value('domain');
|
||||
|
||||
return redirect(is_string($domain) && $domain !== '' ? 'https://'.$domain.'/admin' : url('/admin'));
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTenants::route('/'),
|
||||
'create' => CreateTenant::route('/create'),
|
||||
'edit' => EditTenant::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Tenants\Pages;
|
||||
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTenant extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TenantResource::class;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Tenants\Pages;
|
||||
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTenant extends EditRecord
|
||||
{
|
||||
protected static string $resource = TenantResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Operator\Tenants\Pages;
|
||||
|
||||
use App\Filament\Operator\TenantResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTenants extends ListRecords
|
||||
{
|
||||
protected static string $resource = TenantResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
|
||||
use App\Filament\Resources\FloorPlans\Pages\EditFloorPlan;
|
||||
use App\Filament\Resources\FloorPlans\Pages\ListFloorPlans;
|
||||
use App\Filament\Resources\FloorPlans\Schemas\FloorPlanForm;
|
||||
use App\Filament\Resources\FloorPlans\Tables\FloorPlansTable;
|
||||
use App\Models\FloorPlan;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Floor plan per apartment: picture from the website photos plus rooms drawn on it (section "Grundriss").
|
||||
*/
|
||||
class FloorPlanResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = FloorPlan::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMap;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
|
||||
|
||||
protected static ?string $modelLabel = 'Grundriss';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Grundriss';
|
||||
|
||||
protected static ?int $navigationSort = 5;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return FloorPlanForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return FloorPlansTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListFloorPlans::route('/'),
|
||||
'create' => CreateFloorPlan::route('/create'),
|
||||
'edit' => EditFloorPlan::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Pages;
|
||||
|
||||
use App\Filament\Resources\FloorPlans\FloorPlanResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateFloorPlan extends CreateRecord
|
||||
{
|
||||
protected static string $resource = FloorPlanResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Pages;
|
||||
|
||||
use App\Filament\Resources\FloorPlans\FloorPlanResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditFloorPlan extends EditRecord
|
||||
{
|
||||
protected static string $resource = FloorPlanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Pages;
|
||||
|
||||
use App\Filament\Resources\FloorPlans\FloorPlanResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListFloorPlans extends ListRecords
|
||||
{
|
||||
protected static string $resource = FloorPlanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Schemas;
|
||||
|
||||
use App\Filament\Forms\Components\PhotoSelect;
|
||||
use App\Models\Amenity;
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Property;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class FloorPlanForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(2)
|
||||
->components([
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->unique(ignoreRecord: true)
|
||||
->validationMessages(['unique' => 'Für diese Wohnung gibt es schon einen Grundriss.'])
|
||||
->required()
|
||||
->live(),
|
||||
PhotoSelect::make('photo_id')
|
||||
->label('Grundriss-Bild')
|
||||
->helperText('Rendering oder Plan aus Webseite › Fotos. Ein neues Bild im gleichen Ausschnitt behält die Räume.')
|
||||
->required()
|
||||
->live(),
|
||||
Repeater::make('rooms')
|
||||
->label('Räume')
|
||||
->columnSpanFull()
|
||||
->defaultItems(0)
|
||||
->addActionLabel('Raum hinzufügen')
|
||||
->reorderable()
|
||||
->collapsible()
|
||||
->itemLabel(fn (array $state): string => filled($state['name'] ?? null) ? $state['name'] : 'Neuer Raum')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Hidden::make('id')->default(fn (): string => (string) Str::uuid()),
|
||||
TextInput::make('name')->label('Name')->placeholder('z. B. Schlafzimmer')->required()->maxLength(60)->live(onBlur: true),
|
||||
Toggle::make('is_visible')->label('Auf der Website zeigen')->default(true)->inline(false),
|
||||
ViewField::make('points')
|
||||
->label('Fläche auf dem Grundriss')
|
||||
->view('filament.forms.floor-plan-area')
|
||||
->columnSpanFull()
|
||||
->rules([
|
||||
fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void {
|
||||
if (count(FloorPlan::points(is_string($value) ? $value : null)) < 3) {
|
||||
$fail('Bitte mindestens drei Ecken des Raums auf dem Bild anklicken.');
|
||||
}
|
||||
},
|
||||
]),
|
||||
Textarea::make('description')->label('Beschreibung')->rows(3)->maxLength(400)->columnSpanFull(),
|
||||
PhotoSelect::make('photo_ids')->label('Fotos')->multiple()->helperText('Das erste Foto steht oben, die weiteren als kleine Bilder darunter.'),
|
||||
Select::make('amenity_ids')
|
||||
->label('Ausstattung')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(fn (Get $get): array => Amenity::query()->where('property_id', $get('../../property_id'))->orderBy('sort_order')->pluck('name', 'id')->all())
|
||||
->helperText('Aus Webseite › Ausstattung – nichts doppelt pflegen.'),
|
||||
TextInput::make('hint')
|
||||
->label('Hinweis zur Barrierefreiheit (optional)')
|
||||
->placeholder('z. B. Flache Dusche mit kleiner Kante')
|
||||
->maxLength(160)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Tables;
|
||||
|
||||
use App\Models\FloorPlan;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class FloorPlansTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->paginated(false)
|
||||
->columns([
|
||||
TextColumn::make('property.name')->label('Wohnung'),
|
||||
TextColumn::make('rooms')->label('Räume')
|
||||
->state(fn (FloorPlan $record): string => $record->visibleRooms()->pluck('name')->implode(', ') ?: 'noch keine'),
|
||||
TextColumn::make('updated_at')->label('Geändert')->since(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public static function configure(Schema $schema): Schema
|
||||
SpatieMediaLibraryFileUpload::make('image')
|
||||
->label('Bild')
|
||||
->collection(Photo::COLLECTION)
|
||||
->disk('public')
|
||||
->image()
|
||||
->imageEditor()
|
||||
->maxSize(25 * 1024)
|
||||
|
||||
@@ -28,7 +28,7 @@ public static function configure(Schema $schema): Schema
|
||||
TextInput::make('domain')
|
||||
->label('Domain')
|
||||
->placeholder('www.fewo-stommer.de')
|
||||
->helperText('Leer = Standard-Website für alle Adressen ohne eigene Zuordnung.')
|
||||
->helperText('Leer = Standard-Website, solange es nur diesen Mandanten gibt. Ab dem zweiten Mandanten antwortet nur eine eingetragene Domain.')
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(190),
|
||||
Select::make('theme')
|
||||
|
||||
@@ -3,9 +3,40 @@
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Models\User;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CreateUser extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UserResource::class;
|
||||
|
||||
/**
|
||||
* An address that already belongs to another landlord is attached. The account, its password
|
||||
* and its two-factor setup stay as they are.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$email = is_string($data['email'] ?? null) ? $data['email'] : '';
|
||||
$existing = User::query()->where('email', $email)->first();
|
||||
|
||||
if ($existing === null) {
|
||||
return parent::handleRecordCreation($data);
|
||||
}
|
||||
|
||||
$attributes = [
|
||||
'name' => $data['name'] ?? $existing->name,
|
||||
'role' => $data['role'] ?? $existing->role,
|
||||
];
|
||||
|
||||
if (array_key_exists('admin_mode', $data)) {
|
||||
$attributes['admin_mode'] = $data['admin_mode'];
|
||||
}
|
||||
|
||||
$existing->forceFill($attributes)->save();
|
||||
|
||||
return $existing;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Users\Pages;
|
||||
|
||||
use App\Filament\Resources\Users\UserResource;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
@@ -16,4 +17,22 @@ protected function getHeaderActions(): array
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* A hidden password field must not be writable by a crafted request either.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function mutateFormDataBeforeSave(array $data): array
|
||||
{
|
||||
$actor = auth()->user();
|
||||
$record = $this->getRecord();
|
||||
|
||||
if (! $actor instanceof User || ! $record instanceof User || ! $actor->mayResetCredentials($record)) {
|
||||
unset($data['password']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -21,15 +24,54 @@ public static function configure(Schema $schema): Schema
|
||||
->maxLength(255),
|
||||
TextInput::make('email')
|
||||
->label('E-Mail (Anmeldename)')
|
||||
->helperText('Besteht die E-Mail schon, kommt das Konto zu diesem Mandanten dazu. Passwort und Zwei-Faktor-Anmeldung bleiben.')
|
||||
->email()
|
||||
->required()
|
||||
->unique(ignoreRecord: true)
|
||||
->maxLength(255),
|
||||
->maxLength(255)
|
||||
->rules([
|
||||
fn (?User $record): Closure => function (string $attribute, mixed $value, Closure $fail) use ($record): void {
|
||||
if (! is_string($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$existing = User::query()->where('email', $value)->first();
|
||||
|
||||
if ($existing === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($record !== null) {
|
||||
if ($existing->isNot($record)) {
|
||||
$fail('Diese E-Mail wird schon verwendet.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
if ($tenantId !== null && $existing->tenants()->where('tenants.id', $tenantId)->exists()) {
|
||||
$fail('Diese Person gehört schon zu diesem Mandanten.');
|
||||
}
|
||||
},
|
||||
]),
|
||||
Radio::make('role')
|
||||
->label('Rolle')
|
||||
->helperText('Bestimmt, was die Person darf.')
|
||||
->helperText('Gilt für diesen Mandanten.')
|
||||
->options(UserRole::class)
|
||||
->required()
|
||||
->afterStateHydrated(function (Radio $component, ?User $record): void {
|
||||
if ($record === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
$role = $tenantId !== null ? ($record->roleOn($tenantId) ?? $record->role) : $record->role;
|
||||
|
||||
if ($role !== null) {
|
||||
$component->state($role->value);
|
||||
}
|
||||
})
|
||||
->columnSpanFull(),
|
||||
Radio::make('admin_mode')
|
||||
->label('Ansicht')
|
||||
@@ -42,6 +84,15 @@ public static function configure(Schema $schema): Schema
|
||||
->revealable()
|
||||
->minLength(10)
|
||||
->required(fn (string $operation): bool => $operation === 'create')
|
||||
->visible(function (string $operation, ?User $record): bool {
|
||||
if ($operation === 'create') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$actor = auth()->user();
|
||||
|
||||
return $actor instanceof User && $actor->mayResetCredentials($record);
|
||||
})
|
||||
->dehydrated(fn (?string $state): bool => filled($state)),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Resources\Users\Tables;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@@ -20,7 +22,18 @@ public static function configure(Table $table): Table
|
||||
->columns([
|
||||
TextColumn::make('name')->label('Name')->searchable(),
|
||||
TextColumn::make('email')->label('E-Mail')->searchable(),
|
||||
TextColumn::make('role')->label('Rolle')->badge(),
|
||||
TextColumn::make('role')
|
||||
->label('Rolle')
|
||||
->badge()
|
||||
->state(function (User $record): ?UserRole {
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
if ($tenantId === null) {
|
||||
return $record->role;
|
||||
}
|
||||
|
||||
return $record->roleOn($tenantId) ?? $record->role;
|
||||
}),
|
||||
TextColumn::make('mode')->label('Ansicht')->state(fn (User $record): string => $record->adminMode()->getLabel()),
|
||||
IconColumn::make('two_factor')->label('2FA')->state(fn (User $record): bool => filled($record->getAppAuthenticationSecret()))->boolean(),
|
||||
])
|
||||
@@ -32,12 +45,35 @@ public static function configure(Table $table): Table
|
||||
->color('warning')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Zum Beispiel bei verlorenem Handy: Die Person richtet die Zwei-Faktor-Anmeldung bei der nächsten Anmeldung neu ein.')
|
||||
->visible(fn (User $record): bool => filled($record->getAppAuthenticationSecret()))
|
||||
->visible(function (User $record): bool {
|
||||
$actor = auth()->user();
|
||||
|
||||
return filled($record->getAppAuthenticationSecret())
|
||||
&& $actor instanceof User
|
||||
&& $actor->mayResetCredentials($record);
|
||||
})
|
||||
->action(function (User $record): void {
|
||||
$actor = auth()->user();
|
||||
|
||||
if (! $actor instanceof User || ! $actor->mayResetCredentials($record)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$record->saveAppAuthenticationSecret(null);
|
||||
$record->saveAppAuthenticationRecoveryCodes(null);
|
||||
Notification::make()->title('2FA zurückgesetzt')->success()->send();
|
||||
}),
|
||||
Action::make('revokeAccess')
|
||||
->label('Zugang entziehen')
|
||||
->icon(Heroicon::OutlinedNoSymbol)
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalDescription('Das Konto bleibt bestehen und verliert nur den Zugang zu diesem Mandanten. Passwort und Zwei-Faktor-Anmeldung bleiben.')
|
||||
->visible(fn (User $record): bool => $record->tenants()->count() >= 2)
|
||||
->action(function (User $record): void {
|
||||
$record->revokeCurrentTenant();
|
||||
Notification::make()->title('Zugang entzogen')->success()->send();
|
||||
}),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
use App\Filament\Resources\Users\Schemas\UserForm;
|
||||
use App\Filament\Resources\Users\Tables\UsersTable;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use UnitEnum;
|
||||
|
||||
class UserResource extends Resource
|
||||
@@ -30,6 +32,23 @@ class UserResource extends Resource
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Benutzer';
|
||||
|
||||
/**
|
||||
* Accounts are global. This list shows only people who belong to the landlord that is open.
|
||||
*
|
||||
* @return Builder<User>
|
||||
*/
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
$query = parent::getEloquentQuery();
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
if ($tenantId === null) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return $query->whereHas('tenants', fn (Builder $membership) => $membership->where('tenants.id', $tenantId));
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UserForm::configure($schema);
|
||||
|
||||
@@ -20,7 +20,8 @@ public function confirm(Guest $guest): View
|
||||
return view('marketing-consent', [
|
||||
'title' => 'Anmeldung bestätigt',
|
||||
'message' => 'Vielen Dank! Wir informieren Sie künftig über freie Termine und Angebote. Sie können sich jederzeit wieder abmelden.',
|
||||
'unsubscribeUrl' => URL::signedRoute('marketing.unsubscribe', $guest),
|
||||
'unsubscribeUrl' => $guest->website()?->signedRoute('marketing.unsubscribe', $guest)
|
||||
?? URL::signedRoute('marketing.unsubscribe', $guest),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Models\Booking;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -38,8 +39,8 @@ public function show(Request $request, Booking $booking, AcceptOffer $accept): V
|
||||
'booking' => $booking,
|
||||
'problem' => $problem,
|
||||
'canAnswer' => $booking->status === BookingStatus::OfferSent && $problem === null,
|
||||
'acceptUrl' => URL::temporarySignedRoute('offers.accept', $expires, ['booking' => $booking, 'v' => $version]),
|
||||
'rejectUrl' => URL::temporarySignedRoute('offers.reject', $expires, ['booking' => $booking, 'v' => $version]),
|
||||
'acceptUrl' => $this->signed($booking, 'offers.accept', $expires, $version),
|
||||
'rejectUrl' => $this->signed($booking, 'offers.reject', $expires, $version),
|
||||
'title' => 'Ihr Angebot',
|
||||
]);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ public function reject(Request $request, Booking $booking, RejectOffer $reject):
|
||||
private function answer(Request $request, Booking $booking, callable $action, string $success): RedirectResponse
|
||||
{
|
||||
$version = (int) $request->query('v');
|
||||
$back = URL::temporarySignedRoute('offers.show', now()->addDays(30), ['booking' => $booking, 'v' => $version]);
|
||||
$back = $this->signed($booking, 'offers.show', now()->addDays(30), $version);
|
||||
|
||||
try {
|
||||
$action($version);
|
||||
@@ -72,4 +73,12 @@ private function answer(Request $request, Booking $booking, callable $action, st
|
||||
|
||||
return redirect()->to($back)->with('offer.success', $success);
|
||||
}
|
||||
|
||||
private function signed(Booking $booking, string $name, DateTimeInterface $expiration, int $version): string
|
||||
{
|
||||
$parameters = ['booking' => $booking, 'v' => $version];
|
||||
|
||||
return $booking->website()?->temporarySignedRoute($name, $expiration, $parameters)
|
||||
?? URL::temporarySignedRoute($name, $expiration, $parameters);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\Theme;
|
||||
use App\Themes\ThemeFactory;
|
||||
use Closure;
|
||||
@@ -17,8 +20,42 @@ public function __construct(private ThemeFactory $factory) {}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
app()->instance(Theme::class, $this->factory->forRequest($request)->activate());
|
||||
$context = app(TenantContext::class);
|
||||
$context->forget();
|
||||
|
||||
$theme = $this->factory->forRequest($request)->activate();
|
||||
app()->instance(Theme::class, $theme);
|
||||
|
||||
$tenant = null;
|
||||
|
||||
if ($theme->site->exists && $theme->site->tenant_id !== null) {
|
||||
$tenant = $theme->site->tenant;
|
||||
} elseif (Tenant::query()->count() === 1) {
|
||||
$tenant = Tenant::query()->first();
|
||||
}
|
||||
|
||||
if ($tenant !== null) {
|
||||
if (! $tenant->is_active && ! $this->operatorMayPass($request)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$context->set($tenant);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* A suspended landlord stays reachable for the operator, and the operator panel itself stays open.
|
||||
*/
|
||||
private function operatorMayPass(Request $request): bool
|
||||
{
|
||||
if ($request->is('betreiber', 'betreiber/*')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$user = $request->user();
|
||||
|
||||
return $user instanceof User && $user->is_operator;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
use App\Pricing\PriceQuote;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
@@ -276,9 +277,10 @@ public function submit(CreateReservation $createReservation): void
|
||||
*/
|
||||
private function tooManyRequests(): bool
|
||||
{
|
||||
$tenantKey = (string) (app(TenantContext::class)->id() ?? 'global');
|
||||
$limits = [
|
||||
'booking-request:'.request()->ip() => [config('fewo.spam.per_ip_per_hour'), 3600],
|
||||
'booking-request-email:'.sha1(mb_strtolower($this->email)) => [config('fewo.spam.per_email_per_day'), 86400],
|
||||
'booking-request:'.$tenantKey.':'.request()->ip() => [config('fewo.spam.per_ip_per_hour'), 3600],
|
||||
'booking-request-email:'.$tenantKey.':'.sha1(mb_strtolower($this->email)) => [config('fewo.spam.per_email_per_day'), 86400],
|
||||
'booking-request-all' => [config('fewo.spam.total_per_hour'), 3600],
|
||||
];
|
||||
|
||||
|
||||
@@ -31,7 +31,8 @@ public function envelope(): Envelope
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
with: ['url' => URL::temporarySignedRoute('marketing.confirm', now()->addDays(14), $this->guest)],
|
||||
with: ['url' => $this->guest->website()?->temporarySignedRoute('marketing.confirm', now()->addDays(14), ['guest' => $this->guest])
|
||||
?? URL::temporarySignedRoute('marketing.confirm', now()->addDays(14), $this->guest)],
|
||||
markdown: 'mail.marketing-consent-request',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ public function envelope(): Envelope
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
with: ['url' => URL::temporarySignedRoute('reviews.create', now()->addDays(90), $this->booking)],
|
||||
with: ['url' => $this->booking->website()?->temporarySignedRoute('reviews.create', now()->addDays(90), ['booking' => $this->booking])
|
||||
?? URL::temporarySignedRoute('reviews.create', now()->addDays(90), $this->booking)],
|
||||
markdown: 'mail.review-request',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\AmenityArea;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\AmenityFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -16,7 +17,7 @@
|
||||
class Amenity extends Model
|
||||
{
|
||||
/** @use HasFactory<AmenityFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\AppearanceFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
@@ -19,7 +20,7 @@
|
||||
class Appearance extends Model
|
||||
{
|
||||
/** @use HasFactory<AppearanceFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Texts an appearance can replace, with their admin labels. Sections read them through Theme::text().
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Observers\BlockedPeriodObserver;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\BlockedPeriodFactory;
|
||||
@@ -22,7 +23,7 @@
|
||||
class BlockedPeriod extends Model
|
||||
{
|
||||
/** @use HasFactory<BlockedPeriodFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
+38
-2
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\ReferralSource;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Observers\BookingObserver;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\BookingFactory;
|
||||
@@ -65,15 +66,41 @@
|
||||
class Booking extends Model
|
||||
{
|
||||
/** @use HasFactory<BookingFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::created(function (Booking $booking): void {
|
||||
$booking->forceFill(['reference' => $booking->created_at->format('Y').'-'.str_pad((string) $booking->id, 4, '0', STR_PAD_LEFT)])->saveQuietly();
|
||||
$booking->forceFill(['reference' => $booking->nextReference()])->saveQuietly();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Next booking number of this landlord in the year of creation, continuing after the highest
|
||||
* number already issued. Existing numbers are never rewritten.
|
||||
*/
|
||||
public function nextReference(): string
|
||||
{
|
||||
$year = $this->created_at->format('Y');
|
||||
|
||||
$references = static::withoutGlobalScope('tenant')
|
||||
->where('tenant_id', $this->tenant_id)
|
||||
->where('reference', 'like', $year.'-%')
|
||||
->whereKeyNot($this->id)
|
||||
->lockForUpdate()
|
||||
->pluck('reference');
|
||||
|
||||
$number = 1;
|
||||
|
||||
foreach ($references as $reference) {
|
||||
if (is_string($reference) && preg_match('/-(\d+)$/', $reference, $match) === 1) {
|
||||
$number = max($number, ((int) $match[1]) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return $year.'-'.str_pad((string) $number, 4, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
@@ -199,4 +226,13 @@ public function isHoldActive(): bool
|
||||
{
|
||||
return in_array($this->status, BookingStatus::holding(), true) && $this->hold_expires_at?->isFuture();
|
||||
}
|
||||
|
||||
/**
|
||||
* The website this stay belongs to, regardless of which landlord is current.
|
||||
*/
|
||||
public function website(): ?Site
|
||||
{
|
||||
return $this->property()->withoutGlobalScope('tenant')->first()
|
||||
?->site()->withoutGlobalScope('tenant')->first();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Channels\ChannelRegistry;
|
||||
use App\Channels\Contracts\ChannelConnector;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ChannelFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
@@ -24,7 +25,7 @@
|
||||
class Channel extends Model
|
||||
{
|
||||
/** @use HasFactory<ChannelFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -9,6 +10,8 @@
|
||||
#[Fillable(['channel_id', 'successful', 'events', 'added', 'changed', 'removed', 'conflicts', 'message', 'duration_ms'])]
|
||||
class ChannelSyncLog extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
public const UPDATED_AT = null;
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ChannelTaskAction;
|
||||
use App\Enums\ChannelTaskStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ChannelTaskFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -20,7 +21,7 @@
|
||||
class ChannelTask extends Model
|
||||
{
|
||||
/** @use HasFactory<ChannelTaskFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Guest;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Tenancy\TenantContextMissing;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Every row belongs to exactly one landlord. When a landlord is current, queries only see that
|
||||
* landlord. Inserts copy the landlord from the parent row, then from the current context.
|
||||
*
|
||||
* @mixin Model
|
||||
*/
|
||||
trait BelongsToTenant
|
||||
{
|
||||
public function initializeBelongsToTenant(): void
|
||||
{
|
||||
$this->mergeFillable(['tenant_id']);
|
||||
}
|
||||
|
||||
public static function bootBelongsToTenant(): void
|
||||
{
|
||||
static::addGlobalScope('tenant', function (Builder $builder): void {
|
||||
$context = app(TenantContext::class);
|
||||
|
||||
if ($context->id() !== null) {
|
||||
$builder->where($builder->getModel()->qualifyColumn('tenant_id'), $context->id());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($context->isRequired()) {
|
||||
throw new TenantContextMissing($builder->getModel()::class);
|
||||
}
|
||||
});
|
||||
|
||||
static::creating(function (Model $model): void {
|
||||
$inherited = self::tenantIdFromParent($model);
|
||||
|
||||
if ($inherited !== null) {
|
||||
$model->setAttribute('tenant_id', $inherited);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (filled($model->getAttribute('tenant_id'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current = app(TenantContext::class)->id();
|
||||
|
||||
if ($current !== null) {
|
||||
$model->setAttribute('tenant_id', $current);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (app()->runningUnitTests() && ! app(TenantContext::class)->isRequired()) {
|
||||
$model->setAttribute('tenant_id', Tenant::query()->create([
|
||||
'name' => 'Testmandant',
|
||||
'slug' => 'test-'.Str::lower(Str::random(10)),
|
||||
])->id);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
throw new TenantContextMissing($model::class);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Tenant, $this>
|
||||
*/
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* The parent row wins, so a booking cannot land on a different landlord than its apartment.
|
||||
*/
|
||||
private static function tenantIdFromParent(Model $model): ?int
|
||||
{
|
||||
$parents = [
|
||||
'property_id' => Property::class,
|
||||
'booking_id' => Booking::class,
|
||||
'channel_id' => Channel::class,
|
||||
'site_id' => Site::class,
|
||||
'guest_id' => Guest::class,
|
||||
];
|
||||
|
||||
foreach ($parents as $column => $class) {
|
||||
$id = $model->getAttribute($column);
|
||||
|
||||
if (! $id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tenantId = $class::withoutGlobalScope('tenant')->whereKey($id)->value('tenant_id');
|
||||
|
||||
if ($tenantId !== null) {
|
||||
return (int) $tenantId;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
@@ -9,4 +10,7 @@
|
||||
* Value of an editable website text; the available keys are defined in config/content.php.
|
||||
*/
|
||||
#[Fillable(['key', 'value'])]
|
||||
class ContentBlock extends Model {}
|
||||
class ContentBlock extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ExtraPricing;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ExtraFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -18,7 +19,7 @@
|
||||
class Extra extends Model
|
||||
{
|
||||
/** @use HasFactory<ExtraFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\FaqFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -13,7 +14,7 @@
|
||||
class Faq extends Model
|
||||
{
|
||||
/** @use HasFactory<FaqFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\FloorPlanFactory;
|
||||
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\Support\Collection;
|
||||
|
||||
/**
|
||||
* Floor plan of an apartment: a picture (rendering or scan) from the website photos and the rooms drawn
|
||||
* on it. Room corners are stored in percent of the picture, so the areas fit every picture size.
|
||||
*
|
||||
* @property list<array{id?: string, name?: string, description?: string, hint?: string, points?: string, photo_ids?: list<int|string>, amenity_ids?: list<int|string>, is_visible?: bool}>|null $rooms
|
||||
*/
|
||||
#[Fillable(['property_id', 'photo_id', 'rooms'])]
|
||||
class FloorPlan extends Model
|
||||
{
|
||||
/** @use HasFactory<FloorPlanFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'rooms' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Property, $this>
|
||||
*/
|
||||
public function property(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Photo, $this>
|
||||
*/
|
||||
public function photo(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Photo::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Rooms shown on the website: visible and with an area of at least three corners.
|
||||
*
|
||||
* @return Collection<int, array<string, mixed>>
|
||||
*/
|
||||
public function visibleRooms(): Collection
|
||||
{
|
||||
return collect($this->rooms ?? [])
|
||||
->filter(fn (array $room): bool => ($room['is_visible'] ?? true) && filled($room['name'] ?? null) && count(self::points($room['points'] ?? null)) >= 3)
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses "x,y x,y …" (percent) into points, ignoring anything outside 0–100.
|
||||
*
|
||||
* @return list<array{float, float}>
|
||||
*/
|
||||
public static function points(?string $points): array
|
||||
{
|
||||
$parsed = [];
|
||||
foreach (preg_split('/\s+/', trim((string) $points)) ?: [] as $pair) {
|
||||
if (preg_match('/^(\d{1,3}(?:\.\d+)?),(\d{1,3}(?:\.\d+)?)$/', $pair, $match) && (float) $match[1] <= 100 && (float) $match[2] <= 100) {
|
||||
$parsed[] = [(float) $match[1], (float) $match[2]];
|
||||
}
|
||||
}
|
||||
|
||||
return $parsed;
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\GuestFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -17,7 +18,7 @@
|
||||
class Guest extends Model
|
||||
{
|
||||
/** @use HasFactory<GuestFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
use BelongsToTenant, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -96,4 +97,12 @@ public function anonymize(): void
|
||||
])->save();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The website of this guest's landlord, regardless of which landlord is current.
|
||||
*/
|
||||
public function website(): ?Site
|
||||
{
|
||||
return $this->tenant?->sites()->withoutGlobalScope('tenant')->orderByDesc('is_default')->orderBy('id')->first();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\NoticeTone;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\NoticeFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -17,7 +18,7 @@
|
||||
class Notice extends Model
|
||||
{
|
||||
/** @use HasFactory<NoticeFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\PageFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -18,7 +19,7 @@
|
||||
class Page extends Model
|
||||
{
|
||||
/** @use HasFactory<PageFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
public const HOME = 'start';
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PaymentMethod;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\PaymentFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@@ -16,7 +17,7 @@
|
||||
class Payment extends Model
|
||||
{
|
||||
/** @use HasFactory<PaymentFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\PhotoFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -22,7 +23,7 @@
|
||||
class Photo extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<PhotoFactory> */
|
||||
use HasFactory, InteractsWithMedia;
|
||||
use BelongsToTenant, HasFactory, InteractsWithMedia;
|
||||
|
||||
public const COLLECTION = 'image';
|
||||
|
||||
@@ -44,7 +45,9 @@ protected function casts(): array
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
// Website photos are public files; the app's default disk (FILESYSTEM_DISK=local) is private.
|
||||
$this->addMediaCollection(self::COLLECTION)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\PortalEmailStatus;
|
||||
use App\Enums\PortalEmailType;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -15,6 +16,8 @@
|
||||
#[Fillable(['channel_id', 'message_id', 'from', 'subject', 'received_at', 'type', 'status', 'starts_on', 'ends_on', 'reference', 'blocked_period_id', 'excerpt', 'note'])]
|
||||
class PortalEmail extends Model
|
||||
{
|
||||
use BelongsToTenant;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
|
||||
+20
-1
@@ -2,12 +2,15 @@
|
||||
|
||||
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.
|
||||
@@ -36,7 +39,7 @@
|
||||
class Property extends Model
|
||||
{
|
||||
/** @use HasFactory<PropertyFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -68,6 +71,14 @@ protected function casts(): array
|
||||
/**
|
||||
* @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');
|
||||
@@ -105,6 +116,14 @@ 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>
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ReviewStatus;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\ReviewFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Scope;
|
||||
@@ -38,7 +39,7 @@
|
||||
class Review extends Model
|
||||
{
|
||||
/** @use HasFactory<ReviewFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/** Rating categories besides the overall rating, with their German labels. */
|
||||
public const CATEGORIES = [
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\SeasonFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
@@ -19,7 +20,7 @@
|
||||
class Season extends Model
|
||||
{
|
||||
/** @use HasFactory<SeasonFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
+99
-1
@@ -2,12 +2,16 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\SiteFactory;
|
||||
use DateInterval;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
/**
|
||||
* A website: domain, theme with its settings, pages and appearances, and the properties it shows.
|
||||
@@ -17,7 +21,14 @@
|
||||
class Site extends Model
|
||||
{
|
||||
/** @use HasFactory<SiteFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saved(function (Site $site): void {
|
||||
$site->syncDomainHost();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -32,6 +43,93 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<SiteDomain, $this>
|
||||
*/
|
||||
public function domains(): HasMany
|
||||
{
|
||||
return $this->hasMany(SiteDomain::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scheme and host for guest links. Empty while the website has no hostname yet.
|
||||
*/
|
||||
public function origin(): ?string
|
||||
{
|
||||
$host = $this->domains()->value('host') ?: $this->domain;
|
||||
|
||||
if (! is_string($host) || $host === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$scheme = in_array($host, ['localhost', '127.0.0.1'], true) ? 'http' : 'https';
|
||||
|
||||
return $scheme.'://'.$host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $parameters
|
||||
*/
|
||||
public function temporarySignedRoute(string $name, DateTimeInterface|DateInterval|int $expiration, array $parameters = []): string
|
||||
{
|
||||
return $this->withOrigin(fn (): string => URL::temporarySignedRoute($name, $expiration, $parameters));
|
||||
}
|
||||
|
||||
public function signedRoute(string $name, mixed $parameters = []): string
|
||||
{
|
||||
return $this->withOrigin(fn (): string => URL::signedRoute($name, $parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep the single domain field and the host table on the same hostname.
|
||||
*/
|
||||
public function syncDomainHost(): void
|
||||
{
|
||||
if (! $this->wasRecentlyCreated && ! $this->wasChanged('domain')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$previous = $this->getOriginal('domain');
|
||||
|
||||
if (is_string($previous) && $previous !== '' && $previous !== $this->domain) {
|
||||
$this->domains()->where('host', mb_strtolower($previous))->delete();
|
||||
}
|
||||
|
||||
if (! is_string($this->domain) || $this->domain === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
SiteDomain::query()->updateOrCreate(
|
||||
['host' => mb_strtolower($this->domain)],
|
||||
['site_id' => $this->id],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(): string $callback
|
||||
*/
|
||||
private function withOrigin(callable $callback): string
|
||||
{
|
||||
$origin = $this->origin();
|
||||
|
||||
if ($origin === null) {
|
||||
return $callback();
|
||||
}
|
||||
|
||||
$generator = app('url');
|
||||
$previousRoot = (fn () => $this->forcedRoot)->call($generator);
|
||||
$previousScheme = (fn () => $this->forceScheme)->call($generator);
|
||||
URL::forceRootUrl($origin);
|
||||
URL::forceScheme(parse_url($origin, PHP_URL_SCHEME) ?: 'https');
|
||||
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
URL::forceRootUrl($previousRoot);
|
||||
URL::forceScheme(is_string($previousScheme) ? strstr($previousScheme, ':', true) : null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Page, $this>
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* One hostname of a website. A host belongs to exactly one website.
|
||||
*/
|
||||
#[Fillable(['site_id', 'host'])]
|
||||
class SiteDomain extends Model
|
||||
{
|
||||
/**
|
||||
* @return BelongsTo<Site, $this>
|
||||
*/
|
||||
public function site(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\DiscountType;
|
||||
use App\Enums\OfferKind;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Pricing\StayRequest;
|
||||
use App\Support\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
@@ -48,7 +49,7 @@
|
||||
class SpecialOffer extends Model
|
||||
{
|
||||
/** @use HasFactory<SpecialOfferFactory> */
|
||||
use HasFactory;
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\TenantFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* A landlord. Owns websites, apartments, guests, bookings and settings. One account can belong
|
||||
* to several landlords; the operator is not a landlord.
|
||||
*/
|
||||
#[Fillable(['name', 'slug', 'is_active'])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
/** @use HasFactory<TenantFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The landlord the existing single-website data belongs to.
|
||||
*/
|
||||
public static function stommer(): self
|
||||
{
|
||||
return static::query()->firstOrCreate(
|
||||
['slug' => 'stommer'],
|
||||
['name' => 'Stommer'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Site, $this>
|
||||
*/
|
||||
public function sites(): HasMany
|
||||
{
|
||||
return $this->hasMany(Site::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return HasMany<Property, $this>
|
||||
*/
|
||||
public function properties(): HasMany
|
||||
{
|
||||
return $this->hasMany(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<User, $this>
|
||||
*/
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class)->withPivot('role')->withTimestamps();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Written when an operator opens a landlord's admin. Support access stays visible.
|
||||
*/
|
||||
#[Fillable(['tenant_id', 'user_id', 'created_at'])]
|
||||
class TenantAccessLog extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::creating(function (TenantAccessLog $log): void {
|
||||
$log->created_at ??= now();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Tenant, $this>
|
||||
*/
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<User, $this>
|
||||
*/
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
+169
-3
@@ -5,6 +5,7 @@
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\Enums\AdminMode;
|
||||
use App\Enums\UserRole;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Database\Factories\UserFactory;
|
||||
use Filament\Auth\MultiFactor\App\Concerns\InteractsWithAppAuthentication;
|
||||
use Filament\Auth\MultiFactor\App\Concerns\InteractsWithAppAuthenticationRecovery;
|
||||
@@ -15,6 +16,7 @@
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
use Illuminate\Database\Eloquent\Attributes\Hidden;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
@@ -25,12 +27,24 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
/** @use HasFactory<UserFactory> */
|
||||
use HasFactory, InteractsWithAppAuthentication, InteractsWithAppAuthenticationRecovery, Notifiable;
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saved(function (User $user): void {
|
||||
$user->attachCurrentRole();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Accounts are created by administrators only; an account without a role has no access.
|
||||
* The operator panel is only for operators. The landlord admin needs a role there, or the operator flag.
|
||||
* Password and two-factor belong to the account and are not a per-landlord setting.
|
||||
*/
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
return $this->role !== null;
|
||||
if ($panel->getId() === 'operator') {
|
||||
return (bool) $this->is_operator;
|
||||
}
|
||||
|
||||
return $this->currentRole() !== null || (bool) $this->is_operator;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,7 +57,158 @@ public function adminMode(): AdminMode
|
||||
|
||||
public function hasRole(UserRole ...$roles): bool
|
||||
{
|
||||
return in_array($this->role, $roles, true);
|
||||
return in_array($this->currentRole(), $roles, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Role inside the landlord that is current. The operator acts as administrator of whichever landlord is open.
|
||||
* With exactly one landlord, the old account role still applies until a membership exists.
|
||||
*/
|
||||
public function currentRole(): ?UserRole
|
||||
{
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
if ($tenantId !== null) {
|
||||
if ($this->is_operator) {
|
||||
return UserRole::Admin;
|
||||
}
|
||||
|
||||
$role = $this->roleOn($tenantId);
|
||||
|
||||
if ($role !== null) {
|
||||
return $role;
|
||||
}
|
||||
|
||||
if ($this->role !== null && Tenant::query()->count() === 1) {
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->role !== null) {
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
if ($this->is_operator) {
|
||||
return UserRole::Admin;
|
||||
}
|
||||
|
||||
$memberships = $this->tenants()->get();
|
||||
|
||||
if ($memberships->count() === 1) {
|
||||
return $this->roleFromPivot($memberships->first()?->pivot?->role);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function roleOn(int $tenantId): ?UserRole
|
||||
{
|
||||
$membership = $this->tenants()->where('tenants.id', $tenantId)->first();
|
||||
|
||||
return $this->roleFromPivot($membership?->pivot?->role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the account role onto the current landlord. Does nothing without a role or a landlord.
|
||||
*/
|
||||
public function attachCurrentRole(?Tenant $tenant = null): void
|
||||
{
|
||||
if ($this->role === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tenant ??= app(TenantContext::class)->get();
|
||||
|
||||
if ($tenant === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadyMember = $this->tenants()->where('tenants.id', $tenant->id)->exists();
|
||||
|
||||
if ($alreadyMember) {
|
||||
if ($this->wasChanged('role')) {
|
||||
$this->tenants()->updateExistingPivot($tenant->id, ['role' => $this->role->value]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->tenants()->attach($tenant->id, ['role' => $this->role->value]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Password and two-factor stay on the account. A landlord admin may reset them only when the
|
||||
* account belongs to no other landlord. Otherwise only the operator may.
|
||||
*/
|
||||
public function mayResetCredentials(?User $other): bool
|
||||
{
|
||||
if ($this->is_operator) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (! $this->hasRole(UserRole::Admin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($other === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $other->tenants()->count() < 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Another landlord this account belongs to, when that landlord has its own domain.
|
||||
*/
|
||||
public function otherTenantAdminUrl(): ?string
|
||||
{
|
||||
$current = app(TenantContext::class)->id();
|
||||
$other = $this->tenants()->where('tenants.id', '!=', $current)->first();
|
||||
|
||||
if ($other === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$domain = $other->sites()->withoutGlobalScope('tenant')->whereNotNull('domain')->value('domain');
|
||||
|
||||
if (! is_string($domain) || $domain === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'https://'.$domain.'/admin';
|
||||
}
|
||||
|
||||
public function showsTenantSwitch(): bool
|
||||
{
|
||||
return $this->otherTenantAdminUrl() !== null;
|
||||
}
|
||||
|
||||
public function revokeCurrentTenant(): void
|
||||
{
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
if ($tenantId !== null) {
|
||||
$this->tenants()->detach($tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsToMany<Tenant, $this>
|
||||
*/
|
||||
public function tenants(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tenant::class)->withPivot('role')->withTimestamps();
|
||||
}
|
||||
|
||||
private function roleFromPivot(mixed $role): ?UserRole
|
||||
{
|
||||
if ($role instanceof UserRole) {
|
||||
return $role;
|
||||
}
|
||||
|
||||
return is_string($role) ? UserRole::tryFrom($role) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,6 +223,7 @@ protected function casts(): array
|
||||
'password' => 'hashed',
|
||||
'role' => UserRole::class,
|
||||
'admin_mode' => AdminMode::class,
|
||||
'is_operator' => 'boolean',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,12 @@ private function occupies(BookingStatus|string|null $status): bool
|
||||
|
||||
private function tasks(Booking $booking, ChannelTaskAction $action): void
|
||||
{
|
||||
$this->createChannelTasks->handle($booking->property, $booking->arrival, $booking->departure, $action, "Buchung {$booking->reference}");
|
||||
$property = $booking->property()->withoutGlobalScope('tenant')->first();
|
||||
|
||||
if ($property === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->createChannelTasks->handle($property, $booking->arrival, $booking->departure, $action, "Buchung {$booking->reference}");
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class AmenityPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class AppearancePolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class BlockedPeriodPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Bookings;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class BookingPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Bookings;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class ChannelTaskPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Channels;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class FaqPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Permission;
|
||||
|
||||
class FloorPlanPolicy extends RolePolicy
|
||||
{
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class GuestPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Guests;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class NoticePolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class PagePolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class PhotoPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Content];
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class PortalEmailPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Channels;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class PropertyPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals];
|
||||
return Permission::Properties;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
|
||||
class ReviewPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [UserRole::Rentals, UserRole::Content];
|
||||
return Permission::Reviews;
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,16 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Enums\Permission;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Grants every ability to the roles listed in roles(). Administrators always have access.
|
||||
* Grants every ability that the current membership includes. The operator counts as administrator
|
||||
* of the landlord that is open. A new role is added on UserRole, not in each policy.
|
||||
*/
|
||||
abstract class RolePolicy
|
||||
{
|
||||
/**
|
||||
* @return list<UserRole>
|
||||
*/
|
||||
abstract protected function roles(): array;
|
||||
abstract protected function permission(): Permission;
|
||||
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
@@ -52,6 +50,6 @@ public function reorder(User $user): bool
|
||||
|
||||
protected function allows(User $user): bool
|
||||
{
|
||||
return $user->hasRole(UserRole::Admin, ...$this->roles());
|
||||
return (bool) $user->currentRole()?->grants($this->permission());
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Permission;
|
||||
|
||||
class SitePolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [];
|
||||
return Permission::Settings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Landlords are created and suspended by the operator. Deleting one is a later, separate step.
|
||||
*/
|
||||
class TenantPolicy
|
||||
{
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
return $user->is_operator;
|
||||
}
|
||||
|
||||
public function view(User $user, Tenant $tenant): bool
|
||||
{
|
||||
return $user->is_operator;
|
||||
}
|
||||
|
||||
public function create(User $user): bool
|
||||
{
|
||||
return $user->is_operator;
|
||||
}
|
||||
|
||||
public function update(User $user, Tenant $tenant): bool
|
||||
{
|
||||
return $user->is_operator;
|
||||
}
|
||||
|
||||
public function delete(User $user, Tenant $tenant): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteAny(User $user): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,26 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Permission;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Only administrators manage accounts; nobody can delete their own account.
|
||||
* Only administrators of the current landlord manage accounts. A shared account is detached, not deleted,
|
||||
* and nobody can delete their own account.
|
||||
*/
|
||||
class UserPolicy extends RolePolicy
|
||||
{
|
||||
protected function roles(): array
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return [];
|
||||
return Permission::Users;
|
||||
}
|
||||
|
||||
public function delete(User $user, ?User $model = null): bool
|
||||
{
|
||||
return $this->allows($user) && ! $user->is($model);
|
||||
if (! $this->allows($user) || $user->is($model)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $model === null || $model->tenants()->count() < 2;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Support\Settings;
|
||||
use App\Support\StripImageMetadata;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@@ -16,7 +17,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
$this->app->singleton(TenantContext::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Enums\AdminMode;
|
||||
use App\Http\Middleware\ResolveTheme;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Auth\MultiFactor\App\AppAuthentication;
|
||||
@@ -49,6 +50,11 @@ public function panel(Panel $panel): Panel
|
||||
isRequired: true,
|
||||
)
|
||||
->userMenuItems([
|
||||
'tenant-switch' => Action::make('switchTenant')
|
||||
->label('Anderer Mandant')
|
||||
->icon(Heroicon::OutlinedArrowsRightLeft)
|
||||
->visible(fn (): bool => self::currentUser()?->showsTenantSwitch() ?? false)
|
||||
->url(fn (): ?string => self::currentUser()?->otherTenantAdminUrl()),
|
||||
'admin-mode' => Action::make('switchAdminMode')
|
||||
->label(fn (): string => (self::currentUser()?->adminMode() ?? AdminMode::Expert)->other()->switchLabel())
|
||||
->icon(fn (): Heroicon => self::currentUser()?->adminMode() === AdminMode::Simple ? Heroicon::OutlinedAdjustmentsHorizontal : Heroicon::OutlinedSparkles)
|
||||
@@ -79,6 +85,7 @@ public function panel(Panel $panel): Panel
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
ResolveTheme::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
PreventRequestForgery::class,
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Http\Middleware\ResolveTheme;
|
||||
use Filament\Auth\MultiFactor\App\AppAuthentication;
|
||||
use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
use Filament\Pages\Dashboard;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Colors\Color;
|
||||
use Filament\Widgets\AccountWidget;
|
||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class OperatorPanelProvider extends PanelProvider
|
||||
{
|
||||
public function panel(Panel $panel): Panel
|
||||
{
|
||||
return $panel
|
||||
->id('operator')
|
||||
->path('betreiber')
|
||||
->login()
|
||||
->profile(isSimple: false)
|
||||
->multiFactorAuthentication(
|
||||
[AppAuthentication::make()->brandName('FeWo Stommer')->recoverable()],
|
||||
isRequired: true,
|
||||
)
|
||||
->brandName('Betreiber')
|
||||
->colors([
|
||||
'primary' => Color::Slate,
|
||||
])
|
||||
->discoverResources(in: app_path('Filament/Operator'), for: 'App\Filament\Operator')
|
||||
->pages([
|
||||
Dashboard::class,
|
||||
])
|
||||
->widgets([
|
||||
AccountWidget::class,
|
||||
])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
StartSession::class,
|
||||
ResolveTheme::class,
|
||||
AuthenticateSession::class,
|
||||
ShareErrorsFromSession::class,
|
||||
PreventRequestForgery::class,
|
||||
SubstituteBindings::class,
|
||||
DisableBladeIconComponents::class,
|
||||
DispatchServingFilamentEvent::class,
|
||||
])
|
||||
->authMiddleware([
|
||||
Authenticate::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
+14
-2
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Models\ContentBlock;
|
||||
use App\Models\Photo;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\HtmlString;
|
||||
@@ -54,7 +55,7 @@ public static function save(array $values): void
|
||||
ContentBlock::updateOrCreate(['key' => $key], ['value' => $value]);
|
||||
}
|
||||
|
||||
Cache::forget(self::CACHE_KEY);
|
||||
Cache::forget(self::cacheKey());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,6 +85,17 @@ private static function definition(string $key): array
|
||||
*/
|
||||
private static function stored(): array
|
||||
{
|
||||
return Cache::rememberForever(self::CACHE_KEY, fn (): array => ContentBlock::pluck('value', 'key')->all());
|
||||
return Cache::rememberForever(self::cacheKey(), fn (): array => ContentBlock::pluck('value', 'key')->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored texts are cached per landlord. Without a current landlord the key stays the historical one,
|
||||
* which only happens before a request has chosen a website.
|
||||
*/
|
||||
private static function cacheKey(): string
|
||||
{
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
return $tenantId === null ? self::CACHE_KEY : self::CACHE_KEY.'.'.$tenantId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tenancy;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Points every existing row at the landlord "Stommer". Used once, when tenancy is introduced
|
||||
* on a database that already has the single-landlord data. Fresh databases have nothing to assign.
|
||||
*/
|
||||
class AssignLegacyData
|
||||
{
|
||||
/**
|
||||
* Tables that gain a tenant_id. Order is irrelevant; nothing is deleted.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public const TABLES = [
|
||||
'sites',
|
||||
'properties',
|
||||
'guests',
|
||||
'bookings',
|
||||
'channels',
|
||||
'portal_emails',
|
||||
'photos',
|
||||
'pages',
|
||||
'appearances',
|
||||
'notices',
|
||||
'faqs',
|
||||
'blocked_periods',
|
||||
'amenities',
|
||||
'reviews',
|
||||
'channel_tasks',
|
||||
'payments',
|
||||
'seasons',
|
||||
'extras',
|
||||
'special_offers',
|
||||
'channel_sync_logs',
|
||||
'content_blocks',
|
||||
];
|
||||
|
||||
public static function run(): void
|
||||
{
|
||||
$pending = false;
|
||||
|
||||
foreach (self::TABLES as $table) {
|
||||
if (DB::table($table)->whereNull('tenant_id')->exists()) {
|
||||
$pending = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tenantId = DB::table('tenants')->where('slug', 'stommer')->value('id');
|
||||
|
||||
if ($tenantId === null) {
|
||||
$tenantId = DB::table('tenants')->insertGetId([
|
||||
'name' => 'Stommer',
|
||||
'slug' => 'stommer',
|
||||
'is_active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (self::TABLES as $table) {
|
||||
DB::table($table)->whereNull('tenant_id')->update(['tenant_id' => $tenantId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tenancy;
|
||||
|
||||
use App\Models\Tenant;
|
||||
|
||||
/**
|
||||
* The landlord of the current request, job or command. Empty means "not chosen yet".
|
||||
* While presence is required, a query on a tenant-owned model without a landlord fails closed.
|
||||
*/
|
||||
class TenantContext
|
||||
{
|
||||
private ?Tenant $tenant = null;
|
||||
|
||||
private bool $required = false;
|
||||
|
||||
public function set(Tenant $tenant): void
|
||||
{
|
||||
$this->tenant = $tenant;
|
||||
}
|
||||
|
||||
public function forget(): void
|
||||
{
|
||||
$this->tenant = null;
|
||||
$this->required = false;
|
||||
}
|
||||
|
||||
public function get(): ?Tenant
|
||||
{
|
||||
return $this->tenant;
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->tenant?->id;
|
||||
}
|
||||
|
||||
public function requirePresence(bool $required = true): void
|
||||
{
|
||||
$this->required = $required;
|
||||
}
|
||||
|
||||
public function isRequired(): bool
|
||||
{
|
||||
return $this->required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a callback as $tenant, then restore whoever was current before.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param callable(): T $callback
|
||||
* @return T
|
||||
*/
|
||||
public function run(Tenant $tenant, callable $callback): mixed
|
||||
{
|
||||
$previous = $this->tenant;
|
||||
$this->tenant = $tenant;
|
||||
|
||||
try {
|
||||
return $callback();
|
||||
} finally {
|
||||
$this->tenant = $previous;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tenancy;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* A tenant-owned query or insert ran without a current landlord while one was required.
|
||||
*/
|
||||
class TenantContextMissing extends RuntimeException
|
||||
{
|
||||
public function __construct(string $model)
|
||||
{
|
||||
parent::__construct("No current tenant for [{$model}].");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Models\Amenity;
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Photo;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Interactive floor plan of the apartment (Admin › Webseite › Grundriss): guests tap a room and see its
|
||||
* photos, equipment and accessibility hint. Without JavaScript the rooms are listed below the plan.
|
||||
*/
|
||||
class FloorPlanSection extends Section
|
||||
{
|
||||
public static function key(): string
|
||||
{
|
||||
return 'floor_plan';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Grundriss (interaktiv)';
|
||||
}
|
||||
|
||||
public static function icon(): string
|
||||
{
|
||||
return 'heroicon-o-map';
|
||||
}
|
||||
|
||||
public static function schema(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('heading')->label('Überschrift')->default('Der Grundriss')->maxLength(120)
|
||||
->helperText('Bild und Räume pflegen Sie unter Webseite › Grundriss.'),
|
||||
Textarea::make('text')->label('Text')->rows(2)->maxLength(300)
|
||||
->default('Tippen Sie auf einen Raum, um Fotos und Ausstattung zu sehen.'),
|
||||
];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
$plan = $theme->property()?->floorPlan()->with('photo')->first();
|
||||
$rooms = $plan?->photo ? $plan->visibleRooms() : collect();
|
||||
|
||||
$photos = Photo::query()->published()->with('media')
|
||||
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['photo_ids'] ?? [])->unique()->all())
|
||||
->get()->keyBy('id');
|
||||
$amenities = Amenity::query()
|
||||
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['amenity_ids'] ?? [])->unique()->all())
|
||||
->pluck('name', 'id');
|
||||
|
||||
return [
|
||||
'heading' => $data['heading'] ?? 'Der Grundriss',
|
||||
'text' => $data['text'] ?? null,
|
||||
'photo' => $plan?->photo,
|
||||
'rooms' => $rooms->map(fn (array $room, int $index): array => [
|
||||
'key' => 'raum-'.Str::slug($room['name']).'-'.($index + 1),
|
||||
'name' => $room['name'],
|
||||
'description' => $room['description'] ?? null,
|
||||
'hint' => $room['hint'] ?? null,
|
||||
'points' => collect(FloorPlan::points($room['points']))->map(fn (array $point): string => $point[0].','.$point[1])->implode(' '),
|
||||
'photos' => collect($room['photo_ids'] ?? [])->map(fn ($id) => $photos->get((int) $id))->filter()->values(),
|
||||
'amenities' => collect($room['amenity_ids'] ?? [])->map(fn ($id) => $amenities->get((int) $id))->filter()->values(),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Site;
|
||||
use App\Models\SiteDomain;
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
@@ -17,7 +19,12 @@ public function __construct(private ThemeRegistry $registry) {}
|
||||
|
||||
public function forRequest(Request $request): Theme
|
||||
{
|
||||
$site = $this->site($request->getHost());
|
||||
$site = $this->siteForRequest($request->getHost());
|
||||
|
||||
if ($site === null) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$isSigned = ($request->query('vorschau') || $request->query('theme')) && $request->hasValidSignature();
|
||||
|
||||
$preview = $isSigned && $request->query('vorschau') ? $site->appearances()->find($request->query('vorschau')) : null;
|
||||
@@ -43,15 +50,63 @@ public function forSite(Site $site, ?Appearance $preview = null, bool $isPreview
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The website for a console command: a matching host, otherwise the default website.
|
||||
*/
|
||||
public function site(?string $host = null): Site
|
||||
{
|
||||
return $this->matchedSite($host) ?? $this->defaultSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* The website for an HTTP request. With two or more landlords an unknown host is not a website.
|
||||
*/
|
||||
public function siteForRequest(?string $host): ?Site
|
||||
{
|
||||
if (! Schema::hasTable('sites')) {
|
||||
return $this->fallbackSite();
|
||||
}
|
||||
|
||||
return ($host ? Site::query()->where('domain', $host)->first() : null)
|
||||
?? Site::query()->where('is_default', true)->first()
|
||||
?? Site::query()->orderBy('id')->first()
|
||||
$matched = $this->matchedSite($host);
|
||||
|
||||
if ($matched !== null) {
|
||||
return $matched;
|
||||
}
|
||||
|
||||
if (Schema::hasTable('tenants') && Tenant::query()->count() > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->defaultSite();
|
||||
}
|
||||
|
||||
private function matchedSite(?string $host): ?Site
|
||||
{
|
||||
$host = is_string($host) ? mb_strtolower(trim($host)) : '';
|
||||
|
||||
if ($host === '' || ! Schema::hasTable('sites')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (Schema::hasTable('site_domains')) {
|
||||
$siteId = SiteDomain::query()->where('host', $host)->value('site_id');
|
||||
|
||||
if ($siteId) {
|
||||
return Site::withoutGlobalScope('tenant')->find($siteId);
|
||||
}
|
||||
}
|
||||
|
||||
return Site::withoutGlobalScope('tenant')->whereRaw('lower(domain) = ?', [$host])->first();
|
||||
}
|
||||
|
||||
private function defaultSite(): Site
|
||||
{
|
||||
if (! Schema::hasTable('sites')) {
|
||||
return $this->fallbackSite();
|
||||
}
|
||||
|
||||
return Site::withoutGlobalScope('tenant')->where('is_default', true)->first()
|
||||
?? Site::withoutGlobalScope('tenant')->orderBy('id')->first()
|
||||
?? $this->fallbackSite();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
use App\Providers\AppServiceProvider;
|
||||
use App\Providers\Filament\AdminPanelProvider;
|
||||
use App\Providers\Filament\OperatorPanelProvider;
|
||||
use App\Providers\ThemeServiceProvider;
|
||||
|
||||
return [
|
||||
AppServiceProvider::class,
|
||||
AdminPanelProvider::class,
|
||||
OperatorPanelProvider::class,
|
||||
ThemeServiceProvider::class,
|
||||
];
|
||||
@@ -39,6 +39,7 @@
|
||||
Sections\TextImageSection::class,
|
||||
Sections\GallerySection::class,
|
||||
Sections\AmenitiesSection::class,
|
||||
Sections\FloorPlanSection::class,
|
||||
Sections\LocationSection::class,
|
||||
Sections\PricesSection::class,
|
||||
Sections\OffersSection::class,
|
||||
|
||||
@@ -36,6 +36,16 @@ public function definition(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (Booking $booking): void {
|
||||
Guest::withoutGlobalScope('tenant')
|
||||
->whereKey($booking->guest_id)
|
||||
->where('tenant_id', '!=', $booking->tenant_id)
|
||||
->update(['tenant_id' => $booking->tenant_id]);
|
||||
});
|
||||
}
|
||||
|
||||
public function reserved(?\DateTimeInterface $holdExpiresAt = null): static
|
||||
{
|
||||
return $this->state(fn (): array => [
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Property;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<FloorPlan>
|
||||
*/
|
||||
class FloorPlanFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'property_id' => Property::factory(),
|
||||
'photo_id' => Photo::factory(),
|
||||
'rooms' => [
|
||||
['id' => (string) Str::uuid(), 'name' => 'Wohnbereich', 'description' => 'Helles Wohnzimmer mit Ledersofa.', 'hint' => null, 'points' => '10,20 50,20 50,65 10,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
|
||||
['id' => (string) Str::uuid(), 'name' => 'Bad', 'description' => 'Bad mit Glasdusche.', 'hint' => 'Flache Dusche mit kleiner Kante.', 'points' => '50,40 66,40 66,65 50,65', 'photo_ids' => [], 'amenity_ids' => [], 'is_visible' => true],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Tenant;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<Tenant>
|
||||
*/
|
||||
class TenantFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
$name = fake()->unique()->company();
|
||||
|
||||
return [
|
||||
'name' => $name,
|
||||
'slug' => Str::slug($name).'-'.Str::lower(Str::random(4)),
|
||||
'is_active' => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\UserRole;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -18,6 +20,22 @@ class UserFactory extends Factory
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
public function configure(): static
|
||||
{
|
||||
return $this->afterCreating(function (User $user): void {
|
||||
if ($user->role === null || app(TenantContext::class)->id() !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tenant = Tenant::query()->count() === 1
|
||||
? Tenant::query()->firstOrFail()
|
||||
: Tenant::factory()->create();
|
||||
|
||||
app(TenantContext::class)->set($tenant);
|
||||
$user->attachCurrentRole($tenant);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
use App\Tenancy\AssignLegacyData;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Add landlords and point every existing row at "Stommer". Columns start nullable so the
|
||||
* assignment can run, then become required. Old code ignores the new columns.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->boolean('is_active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
foreach (AssignLegacyData::TABLES as $name) {
|
||||
Schema::table($name, function (Blueprint $table) {
|
||||
$table->foreignId('tenant_id')->nullable()->constrained()->restrictOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
AssignLegacyData::run();
|
||||
|
||||
foreach (AssignLegacyData::TABLES as $name) {
|
||||
Schema::table($name, function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('tenant_id')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->dropUnique(['reference']);
|
||||
$table->unique(['tenant_id', 'reference']);
|
||||
});
|
||||
|
||||
Schema::table('content_blocks', function (Blueprint $table) {
|
||||
$table->dropUnique(['key']);
|
||||
$table->unique(['tenant_id', 'key']);
|
||||
});
|
||||
|
||||
Schema::table('portal_emails', function (Blueprint $table) {
|
||||
$table->dropUnique(['message_id']);
|
||||
$table->unique(['tenant_id', 'message_id']);
|
||||
});
|
||||
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->dropUnique(['slug']);
|
||||
$table->unique(['tenant_id', 'slug']);
|
||||
});
|
||||
|
||||
Schema::table('guests', function (Blueprint $table) {
|
||||
$table->index(['tenant_id', 'email']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops the landlord assignment. Rows stay; the link to a landlord does not.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('guests', function (Blueprint $table) {
|
||||
$table->dropIndex(['tenant_id', 'email']);
|
||||
});
|
||||
|
||||
Schema::table('properties', function (Blueprint $table) {
|
||||
$table->dropUnique(['tenant_id', 'slug']);
|
||||
$table->unique('slug');
|
||||
});
|
||||
|
||||
Schema::table('portal_emails', function (Blueprint $table) {
|
||||
$table->dropUnique(['tenant_id', 'message_id']);
|
||||
$table->unique('message_id');
|
||||
});
|
||||
|
||||
Schema::table('content_blocks', function (Blueprint $table) {
|
||||
$table->dropUnique(['tenant_id', 'key']);
|
||||
$table->unique('key');
|
||||
});
|
||||
|
||||
Schema::table('bookings', function (Blueprint $table) {
|
||||
$table->dropUnique(['tenant_id', 'reference']);
|
||||
$table->unique('reference');
|
||||
});
|
||||
|
||||
foreach (array_reverse(AssignLegacyData::TABLES) as $name) {
|
||||
Schema::table($name, function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('tenant_id');
|
||||
});
|
||||
}
|
||||
|
||||
Schema::dropIfExists('tenants');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Membership is the role inside one landlord. The operator flag stays off here: it is granted
|
||||
* afterwards with users:promote-operator, never by copying the old global role.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->boolean('is_operator')->default(false);
|
||||
});
|
||||
|
||||
Schema::create('tenant_user', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('role');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['tenant_id', 'user_id']);
|
||||
});
|
||||
|
||||
Schema::create('tenant_access_logs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
|
||||
$tenantId = DB::table('tenants')->where('slug', 'stommer')->value('id');
|
||||
|
||||
if ($tenantId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$now = now();
|
||||
|
||||
foreach (DB::table('users')->whereNotNull('role')->get(['id', 'role']) as $user) {
|
||||
DB::table('tenant_user')->insert([
|
||||
'tenant_id' => $tenantId,
|
||||
'user_id' => $user->id,
|
||||
'role' => $user->role,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops memberships and the operator flag. Accounts and their old role column stay.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('tenant_access_logs');
|
||||
Schema::dropIfExists('tenant_user');
|
||||
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('is_operator');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* A website can answer on more than one host. The existing sites.domain value is the first host.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('site_domains', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('site_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('host')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$now = now();
|
||||
|
||||
foreach (DB::table('sites')->whereNotNull('domain')->where('domain', '!=', '')->get(['id', 'domain']) as $site) {
|
||||
DB::table('site_domains')->insert([
|
||||
'site_id' => $site->id,
|
||||
'host' => mb_strtolower($site->domain),
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('site_domains');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* One floor plan per apartment: a picture from the website photos and the rooms drawn on it.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('floor_plans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('tenant_id')->constrained()->restrictOnDelete();
|
||||
$table->foreignId('property_id')->unique()->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('photo_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->json('rooms')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('floor_plans');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Photo;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Photos uploaded in the admin landed on the private default disk ("local"), so the website could not
|
||||
* show them. Moves their files (original and web sizes, folder = media id) to the public disk.
|
||||
* Safe to run again: only media not yet on the public disk are touched.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$media = DB::table('media')
|
||||
->where('model_type', Photo::class)
|
||||
->where(fn ($query) => $query->where('disk', '!=', 'public')->orWhere('conversions_disk', '!=', 'public'))
|
||||
->get(['id', 'disk', 'conversions_disk']);
|
||||
|
||||
foreach ($media as $item) {
|
||||
$folder = (string) $item->id;
|
||||
$public = Storage::disk('public');
|
||||
$disks = array_values(array_diff(array_unique([$item->disk, $item->conversions_disk ?: $item->disk]), ['public']));
|
||||
|
||||
if (array_filter($disks, fn (string $diskName): bool => config("filesystems.disks.{$diskName}") === null) !== []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($disks as $diskName) {
|
||||
|
||||
$source = Storage::disk($diskName);
|
||||
foreach ($source->allFiles($folder) as $file) {
|
||||
$public->writeStream($file, $source->readStream($file));
|
||||
}
|
||||
$source->deleteDirectory($folder);
|
||||
}
|
||||
|
||||
DB::table('media')->where('id', $item->id)->update(['disk' => 'public', 'conversions_disk' => 'public']);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Files stay public; moving them back to a private disk would hide them from the website again.
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
use App\Enums\ExtraPricing;
|
||||
use App\Models\Property;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
@@ -16,7 +18,11 @@ class PropertySeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$tenant = Tenant::stommer();
|
||||
app(TenantContext::class)->set($tenant);
|
||||
|
||||
$property = Property::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'name' => 'Ferienwohnung Stommer',
|
||||
'slug' => 'ferienwohnung-stommer',
|
||||
'address' => 'Strandstraße 15, 18225 Kühlungsborn',
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
use App\Models\Page;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\Tenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
@@ -19,7 +21,11 @@ class SiteSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$tenantId = Property::withoutGlobalScope('tenant')->value('tenant_id') ?? Tenant::stommer()->id;
|
||||
app(TenantContext::class)->set(Tenant::query()->findOrFail($tenantId));
|
||||
|
||||
$site = Site::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'name' => 'Ferienwohnung Stommer',
|
||||
'domain' => null,
|
||||
'is_default' => true,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\AmenityArea;
|
||||
use App\Models\Faq;
|
||||
use App\Models\Property;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
/**
|
||||
@@ -17,7 +18,8 @@ class WebsiteContentSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$property = Property::query()->firstOrFail();
|
||||
$property = Property::withoutGlobalScope('tenant')->firstOrFail();
|
||||
app(TenantContext::class)->set($property->tenant);
|
||||
|
||||
$amenities = [
|
||||
AmenityArea::General->value => ['Schnelles WLAN kostenlos', 'Pkw-Stellplatz inklusive', 'Abschließbarer Fahrradraum für 2 Räder', 'Diele mit großem Kleiderschrank und Spiegeln'],
|
||||
|
||||
@@ -150,6 +150,7 @@ ## 8. Bekannte Eigenheiten und Lösungen
|
||||
| Nach dem Umschalten lief die alte Version weiter | Strato-OPcache speichert Skripte unter dem Symlink-Pfad `current/…` | `.htaccess` zeigt auf den konkreten Ordner `releases/<version>/public` und wird bei jedem Umschalten neu geschrieben |
|
||||
| Links mit `/current/public` (z. B. Sitemap) | Laravel leitet den Basis-Pfad aus dem Skript-Pfad ab | `URL::forceRootUrl(APP_URL)` außerhalb von local/testing (`AppServiceProvider`) |
|
||||
| HTTP 500 „Composer platform“ | Web-PHP des Pakets ist 8.3 | `AddType application/x-httpd-php84 .php` in der Ordner-`.htaccess` |
|
||||
| Im Admin hochgeladenes Foto erscheint in der Fotoliste, auf der Website/im Grundriss-Editor aber als leeres Bild (HTTP 403) | Upload-Feld nahm Filaments Standard-Speicher `FILESYSTEM_DISK=local` (privat, `storage/app/private/<media-id>`); Import und Website nutzen `public` | Seit 23.10.2026 (`1871c04`): Fotos immer auf `public` (`Photo`-Sammlung `useDisk('public')`, Upload-Feld `->disk('public')`); Migration `2026_10_23_171001_move_photo_media_to_the_public_disk` hat vorhandene private Fotos verschoben (stommer.info: Foto 41). Direkt nach dem Verschieben kann Strato die Adresse kurz noch mit 403 beantworten |
|
||||
| SSH „connection closed“ | falscher Server `ssh.strato.de` | paketspezifischer Server (§2) |
|
||||
| Domain-Ziel `current/public` nicht wählbar | Strato erlaubt kein Symlink-Ziel | Domain auf den Deploy-Ordner, `.htaccess` leitet weiter |
|
||||
| Ersteinrichtung mit Factories schlägt fehl | Produktion ohne Dev-Pakete | `ProductionSeeder` |
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
# Designkonzept – neues Website-Theme
|
||||
|
||||
Stand: 23.10.2026 · Entwurf zur Entscheidung · Umsetzung: [THEME-ERSTELLUNG.md](THEME-ERSTELLUNG.md), Architektur: [THEMES.md](THEMES.md), Zusammenarbeit: [ZUSAMMENARBEIT.md](ZUSAMMENARBEIT.md)
|
||||
|
||||
> **Kurz:** Die Website richtet sich an **Paare**, vor allem ältere und gut situierte Paare mittleren Alters. Sie soll ruhig, hochwertig, sehr gut lesbar und persönlich wirken. Das neue Design entsteht als zusätzliches Theme. Was Vermieter und später ein KI-Vermarktungsassistent saisonal ändern wollen (Farben, Bilder, Texte, Angebote, Banner, Gestaltungsvarianten), wird im Admin gepflegt, nicht im Code. Dafür braucht der Konfigurator einige Erweiterungen (§7). Drei Designrichtungen stehen zur Wahl (§6). Empfehlung: **A „Brigittes Kühlungsborn“**.
|
||||
|
||||
---
|
||||
|
||||
## 1. Auftrag
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| **Was** | Ferienwohnung im Erdgeschoss einer Wohnanlage in Kühlungsborn, 53 m², 1–3 Gäste, Terrasse mit Garten, Sauna im Haus |
|
||||
| **Für wen** | Paare: ältere Paare und gut situierte Paare mittleren Alters. Keine Familien, keine Haustiere |
|
||||
| **Hauptaufgabe der Website** | Vertrauen schaffen und zur **Anfrage** führen (Buchungsweg 1: Anfrage → Angebot → Annahme). Telefonischer Kontakt ist ausdrücklich erwünscht |
|
||||
| **Nebenaufgaben** | Saisonale Aktionen und Lückenfüller bewerben, Nebensaison füllen, Stammgäste binden |
|
||||
|
||||
## 2. Zielgruppe und was daraus folgt
|
||||
|
||||
| Erwartung der Gäste | Folge für Gestaltung und Inhalt |
|
||||
|---|---|
|
||||
| Mühelos lesen und finden | Fließtext ≥ 18 px (Desktop 19–20 px), Zeilenhöhe ≥ 1,6, Zeilen ≤ 70 Zeichen. Kein dünnes Hellgrau, Kontrast ≥ 7:1 für Fließtext angestrebt (AA verlangt 4,5:1). Schaltflächen ≥ 48 px hoch, klare Beschriftung statt Symbolen. Kein Inhalt nur bei Hover oder Wischgeste |
|
||||
| Persönlich und vertrauenswürdig | Gastgeberin mit Namen, persönliche Tipps, echte Fotos. Telefonnummer in Kopf und Fuß sowie in der mobilen Buchungsleiste |
|
||||
| Keine Überraschungen | Gesamtpreis inkl. Endreinigung und Extras, Mindestaufenthalt, Storno, An- und Abreisezeiten, Hausregeln gut auffindbar („Gut zu wissen“) |
|
||||
| Ehrliche Angaben zum Zugang | Klar und ohne Beschönigung: **Erdgeschoss; eine Stufe am Eingang, über den Garten stufenlos; keine Treppen; flache Dusche mit kleiner Kante; nicht rollstuhlgerecht.** (Stufe und Duschkante vor Veröffentlichung vor Ort bestätigen) |
|
||||
| Zeit zu zweit, Ruhe, Genuss | Bilder und Texte ohne Familienszenen. Themen: Spaziergänge, Strand außerhalb der Saison, Bäderarchitektur, Restaurants, Kultur, Sauna, Terrasse |
|
||||
| Qualität wie in einem guten kleinen Hotel | Wenige, große, gute Fotos. Viel Ruhe im Layout. Bewegung nur sparsam (§5) |
|
||||
| Reisen auch im Frühjahr, Herbst und Winter | Jede Jahreszeit hat eine eigene Stimmung (Erscheinungsbilder). Aktionen und Banner reagieren auf Saison und Auslastung |
|
||||
|
||||
**Tonalität:** „Sie“, ruhig, konkret, ohne Werbesprache. Lieber „Vom Sofa sehen Sie in den Garten“ als „Erleben Sie unvergessliche Momente“. Bestehende Texte prüfen, ob sie noch von zwei Gastgebern sprechen.
|
||||
|
||||
## 3. Was die Wohnung erzählt (Inhalte, die schon da sind)
|
||||
|
||||
Aus den 39 vorhandenen Fotos und Daten:
|
||||
|
||||
- **Rückzug zu zweit:** Schlafzimmer mit Boxspringbett und Leseecke, Ledersofa vor der Terrassentür, Relaxsessel
|
||||
- **Draußen:** überdachte Terrasse mit Hortensien, Garten mit Rhododendren, Gartenteich, Sitzplatz im Grünen
|
||||
- **Wohlfühlen:** Sauna im Haus, flache Glasdusche, Arbeitsplatz (für längere Aufenthalte)
|
||||
- **Kühlungsborn:** Strandkörbe, Bootshafen, Molli, Gespensterwald, Villen der Bäderarchitektur, Ostseeallee, Backsteinkirche
|
||||
- **Überblick:** Grundriss (Foto), Luftbilder von Anlage, Wald und Ostsee
|
||||
|
||||
**Fehlt noch / wünschenswert:** Herbst- und Winterbilder (Strand, Promenade, Sauna-Abend), Detailbilder (Frühstück auf der Terrasse, Bücher, zwei Gläser – Stimmung ohne Personen), Brigittes Lieblingsorte für die Tipps. Detail- und Ortsbilder kann Brigitte selbst mit dem Handy machen. Die Website wirkt dabei über Bildausschnitt und Aufbereitung, nicht über Modelle.
|
||||
|
||||
**Gastgeberin:** Brigitte möchte nicht im Mittelpunkt stehen. Der Gastgeber-Baustein funktioniert deshalb auch **ohne Porträt**: Text in ihrer Stimme, Unterschrift, wahlweise ein Stimmungs- oder Detailbild. Ob ältere Fotos der Familie (z. B. im Strandkorb) gezeigt werden, entscheidet allein Brigitte. Das Theme braucht sie nicht.
|
||||
|
||||
## 4. Grundsätze für jedes Design
|
||||
|
||||
1. **Lesbarkeit vor Effekt** – alle Regeln aus §2, in **allen** Erscheinungsbildern (auch dunklen).
|
||||
2. **Anfrage immer in Reichweite** – „Verfügbarkeit prüfen“ und Telefonnummer auf jeder Seite, mobil als feste Leiste.
|
||||
3. **Vertrauen sichtbar machen** – Bewertungen mit Echtheitshinweis, „Gut zu wissen“, Preise transparent, Impressum leicht erreichbar.
|
||||
4. **Eigenständig, nicht austauschbar** – Gestaltung aus Kühlungsborn ableiten: Bäderarchitektur, Backstein, Sanddorn, Kiefern und Buchen, Strandkorb, Ostseelicht. Den verbreiteten „KI-Standard-Look“ vermeiden: Cremegrund mit Serifen-Headline und Terrakotta-Akzent, Großbuchstaben-Etiketten über jeder Überschrift, nummerierte Abschnitte ohne Reihenfolge, gleich aussehende Karten überall.
|
||||
5. **Saisonfähig** – alles, was sich mit Saison und Kampagne ändert, ist Daten im Admin, nicht Code (§7). Das ist die Grundlage für den späteren KI-Vermarktungsassistenten.
|
||||
6. **Mehrsprachig vorbereiten** – Layout verträgt längere deutsche und kürzere englische Texte; Platz für einen Sprachumschalter im Kopf (§8).
|
||||
7. **Datensparsam** – nichts von fremden Servern, Schriften selbst gehostet, kein Cookie-Banner nötig.
|
||||
|
||||
## 5. Bewegung
|
||||
|
||||
Höchstens **ein** ruhiger Moment pro Seite, z. B. das Titelbild blendet beim Laden langsam auf, oder die Grundriss-Räume heben sich beim Antippen hervor. Keine Einflug-Animationen pro Abschnitt, kein Parallax-Rausch, kein Autoplay-Slider. `prefers-reduced-motion` schaltet alles ab. Rollierende Angebote nur mit Pause-Knopf und langsam.
|
||||
|
||||
## 6. Drei Designrichtungen
|
||||
|
||||
Alle drei nutzen die vorhandenen Bausteine und Erscheinungsbilder. Farbwerte sind Standard-Tokens. Erscheinungsbilder überschreiben sie (Kontraste der Startwerte geprüft: Fließtext ≥ 13:1, gedämpfter Text ≥ 6:1, Akzent ≥ 5,4:1).
|
||||
|
||||
### A – „Brigittes Kühlungsborn“ (Empfehlung)
|
||||
|
||||
**Idee:** Ein ruhiges, persönliches Magazin über eine Wohnung und einen Ort. Brigitte erzählt und empfiehlt. Große, gut lesbare Typografie, Fotos wie in einem Reisemagazin, ihre Tipps als roter Faden. Passt zur Zielgruppe (Vertrauen, Genuss, Kultur) und braucht kein Porträt.
|
||||
|
||||
| Token | Wert | Herkunft |
|
||||
|---|---|---|
|
||||
| ground | `#F7F8F6` | Kreideweiß, kühl (bewusst kein Creme) |
|
||||
| ink | `#1F2B38` | Tintenblau |
|
||||
| muted | `#4F5B66` | Schiefer |
|
||||
| accent | `#9A3B2E` | Backstein (Backsteinkirche, Backsteingotik) |
|
||||
| band | `#23384A` | Ostsee am Abend |
|
||||
|
||||
**Schrift:** *Newsreader* (Überschriften und Fließtext, Zeitungs-Serife mit optischen Größen, sehr gut lesbar) + *Atkinson Hyperlegible Next* (Navigation, Formulare, Preise – entwickelt für Menschen mit eingeschränktem Sehvermögen).
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────┐
|
||||
│ Ferienwohnung Stommer Wohnung Kühlungsborn Preise│
|
||||
│ ☎ 038293 … [Anfragen]│
|
||||
├──────────────────────────────┬─────────────────────────┤
|
||||
│ │ Ihr Zuhause zwischen │
|
||||
│ großes Foto (Terrasse) │ Garten und Meer │
|
||||
│ │ kurzer Text │
|
||||
│ │ [Anreise][Abreise][2 P.] │
|
||||
├──────────────────────────────┴─────────────────────────┤
|
||||
│ „Mein Lieblingsplatz ist morgens die Terrasse …“ │
|
||||
│ – Brigitte │
|
||||
├────────────────────────────────────────────────────────┤
|
||||
│ Die Wohnung Text links, 2 Fotos versetzt rechts │
|
||||
│ Grundriss zum Antippen, Fotos je Raum │
|
||||
│ Brigittes Tipps Liste: Ort · zu Fuß 8 Min · warum │
|
||||
│ Gut zu wissen Zugang, An-/Abreise, keine Haustiere │
|
||||
└────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
**Unverwechselbares Element:** Brigittes Tipps mit Gehzeiten ab der Wohnung, als Liste gesetzt wie in einem Reiseführer.
|
||||
**Ausrichtung:** linksbündig, asymmetrisch, viel Weißraum.
|
||||
|
||||
### B – „Weiße Villa“ (Bäderarchitektur, elegant)
|
||||
|
||||
**Idee:** Die Seite wirkt wie eine Villa an der Ostseeallee: hell, symmetrisch, feine Linien. Ein Ornament aus den Balkongittern der Bäderarchitektur dient als Trenner, Fotos haben oben leicht gerundete Ecken wie Fensterbögen. Wirkt am „hochwertigsten“, aber weniger persönlich.
|
||||
|
||||
| Token | Wert | Herkunft |
|
||||
|---|---|---|
|
||||
| ground | `#FFFFFF` | weiße Fassade |
|
||||
| ink | `#22313B` | Schiefer |
|
||||
| muted | `#56636D` | |
|
||||
| accent | `#2F5D50` | Verandagrün |
|
||||
| band | `#2F5D50` | |
|
||||
|
||||
**Schrift:** *Marcellus* (Überschriften, an Inschriften angelehnt) + *Hanken Grotesk* (Text).
|
||||
**Unverwechselbares Element:** Balkon-Ornament als Linie (eigene SVG im Theme-Ordner).
|
||||
**Ausrichtung:** zentriert, symmetrisch.
|
||||
|
||||
### C – „Sanddorn & Kiefer“ (natürlich, jahreszeitlich)
|
||||
|
||||
**Idee:** Natur rund um Kühlungsborn: Kiefernwald, Sanddorn, Buchen im Gespensterwald. Große Fotos über die ganze Breite, kräftige Farbbänder, die mit den Jahreszeiten am deutlichsten wechseln (Sommer Sanddorn, Herbst Buchenlaub, Winter Kiefer und Schnee). Am stärksten saisonal, am wenigsten klassisch.
|
||||
|
||||
| Token | Wert | Herkunft |
|
||||
|---|---|---|
|
||||
| ground | `#F3F5F0` | heller Dünensand, grünlich |
|
||||
| ink | `#1E2A24` | Kiefer, sehr dunkel |
|
||||
| muted | `#4B5850` | |
|
||||
| accent | `#A9460F` | Sanddorn |
|
||||
| band | `#2E4A3C` | Kiefernwald |
|
||||
|
||||
**Schrift:** *Alegreya* (Überschriften) + *Alegreya Sans* (Text) – humanistisch, warm, gut lesbar.
|
||||
**Unverwechselbares Element:** saisonale Farbbänder hinter großen Fotos.
|
||||
**Ausrichtung:** linksbündig, vollflächige Bildstrecken.
|
||||
|
||||
### Entscheidungshilfe
|
||||
|
||||
| | A Brigittes Kühlungsborn | B Weiße Villa | C Sanddorn & Kiefer |
|
||||
|---|---|---|---|
|
||||
| Persönlich | ●●● | ● | ●● |
|
||||
| Hochwertig | ●● | ●●● | ●● |
|
||||
| Lesbarkeit | ●●● | ●● | ●●● |
|
||||
| Saisonal wandelbar | ●● | ● | ●●● |
|
||||
| Ohne neue Fotos stark | ●●● | ●● | ● |
|
||||
|
||||
Kombinationen sind möglich (z. B. A mit den saisonalen Farbbändern aus C). Vor der Entscheidung: Vorbilder ansehen (Awwwards › Hotel & Restaurant, Sawday's, kleine Boutique-Hotels an Nord- und Ostsee) und notieren, was gefällt und was nicht.
|
||||
|
||||
## 7. Erweiterungen des Konfigurators
|
||||
|
||||
Ziel: kein freier Seiten-Editor, sondern **Stellschrauben, die das Theme anbietet** – jede Kombination sieht gut aus. Pflege in der **Expertenansicht**; die einfache Ansicht bleibt bei Inhalten.
|
||||
|
||||
| # | Erweiterung | Admin | Nutzen |
|
||||
|---|---|---|---|
|
||||
| 1 | **Theme-Optionen** in `theme.json › options` (Auswahl/Schalter, z. B. Titelbereich vollflächig/geteilt, Bewegung an/aus, Bildrahmen) | Websites › Theme (Standard) und Erscheinungsbilder (Überschreiben) – erscheinen automatisch wie die Farbfelder | Saisonale Wirkung ohne Code; Grundlage für KI-Assistent |
|
||||
| 2 | **Darstellungsvarianten je Baustein** (`theme.json › variants`, z. B. Galerie: Mosaik/Filmstreifen; Text mit Bild: ruhig/Magazin) | Seiten-Baukasten: Feld „Darstellung“ mit den Varianten des aktiven Themes | Mehr Abwechslung bei gleicher Qualität |
|
||||
| 3 | **Baustein „Grundriss“** – SVG-Grundriss + Räume (Name, Text, Fotos) | Seiten-Baukasten | Orientierung, Zugang verständlich machen |
|
||||
| 4 | **Baustein „Tipps der Gastgeberin“** – Orte mit Kategorie, Gehzeit/Entfernung, Text, Foto, OpenStreetMap-Link; saisonal filterbar | eigene Liste (Webseite › Tipps), Baustein wählt Kategorien | Persönlichkeit ohne Porträt, Inhalte für Nebensaison |
|
||||
| 5 | **Baustein „Gut zu wissen“** – Zugang/Barrieren, An- und Abreise, Haustiere, Rauchen, Parken; strukturiert statt Fließtext | Wohnung › Eigenschaften + Baustein | Vertrauen, weniger Rückfragen; Daten wiederverwendbar (Angebot, Mails, JSON-LD) |
|
||||
| 6 | Gastgeber-Baustein: **Porträt optional**, Unterschrift/Name, Bild beliebig | bestehender Baustein | passt zu Brigittes Wunsch |
|
||||
| 7 | *später:* Video-Baustein (selbst gehostet), Wetter/Wassertemperatur (Lizenz klären), Erzählstrecke „Ein Tag an der Ostsee“ | | |
|
||||
|
||||
Kampagnen sind schon gut abgedeckt (Erscheinungsbilder mit Farben/Bildern/Texten, Sonderangebote mit Hervorhebung, Banner). Das Theme gestaltet diese Flächen als vollwertige Elemente: Angebot im Titelbereich, Banner, Angebotsbaustein in allen drei Darstellungen.
|
||||
|
||||
## 8. Mehrsprachigkeit (Vorbereitung)
|
||||
|
||||
Primär Deutsch. Englisch (und weitere Sprachen) erst, wenn auch die Gästekommunikation (Mails, Angebot, Vertrag, später KI-Antworten) in der Sprache funktioniert. Fürs Design jetzt schon: Sprachumschalter-Platz im Kopf, keine Texte in Grafiken, Layout mit ±30 % Textlänge testen. Für die Anwendung später: übersetzbare Inhalte je Seite/Baustein, Sprach-URLs (`/en/…`), `hreflang`, Sprache am Gast für Mails.
|
||||
|
||||
## 9. Nächste Schritte
|
||||
|
||||
1. **Lars/Brigitte:** Vorbilder ansehen, Richtung wählen (A, B, C oder Kombination); Stufe und Duschkante bestätigen; Brigittes Tipps sammeln (Name, warum, Gehzeit).
|
||||
2. **Entwurf:** für die gewählte Richtung Startseite und Wohnungsseite als Theme auf Branch `theme/<key>`, Vorschau per `themes:preview`, Screenshots auf Handy/Tablet/Desktop.
|
||||
3. **Konfigurator:** Erweiterungen 1, 2, 5, 6 (Grundlage), dann 3 und 4 – auf `feature/theme-options`, mit Tests, Vertragsänderungen in ZUSAMMENARBEIT.md §6.
|
||||
4. **Feinschliff:** alle Bausteine, alle Erscheinungsbilder, Angebots- und Bewertungsseite, Checkliste THEME-ERSTELLUNG.md §10.
|
||||
Loaded 100 of 191 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user