Compare commits

..
3 Commits
Author SHA1 Message Date
Lars StommerandClaude Opus 5.5 2892e6aeab Gästeverzeichnis und Customer Voice
- Gäste: Markierungen, Aufenthalte & Umsatz, Stammgast-/Einwilligungsfilter, CSV-Export, Anonymisierung (manuell + automatisch nach Aufbewahrungsfrist)
- Werbe-Einwilligung per Double-Opt-in aus dem Anfrageformular, signierte Bestätigungs-/Abmeldelinks
- Bewertungen: automatische Einladung nach Abreise, Bewertungsformular mit Kategorien und internem Feedback, Freigabe und öffentliche Antwort im Admin
- Konzept: Rollen, Inhalte, Customer Voice, Architektur Portal-Sync/Buchungshoheit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:26:11 +02:00
Lars StommerandClaude Opus 5.5 bb7eb62782 Inhaltsverwaltung: Bilder, Webseiten-Texte, Ausstattung, FAQ, Hinweis-Banner
- Bilder mit automatischen WebP-Webgrößen (640/1280/2048 px), Sortierung per Drag & Drop, Mehrfach-Upload, Import-Befehl photos:import
- Webseiten-Texte als feste, bearbeitbare Bausteine (config/content.php), Rich-Text bereinigt ausgegeben
- Ausstattung und FAQ aus der bisherigen Webseite übernommen
- Rolle Inhalte hat Zugriff auf alle Webseiten-Bereiche

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:19:51 +02:00
Lars StommerandClaude Opus 5.5 27ea12901e Benutzerrollen (Administrator, Vermietung, Inhalte) und Benutzerverwaltung
- Rollenbasierte Policies, Navigationsgruppen
- Media Library (Spatie) für die kommende Bildverwaltung installiert

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 10:13:55 +02:00
120 changed files with 4809 additions and 105 deletions

No files matched your search

+2
View File
@@ -71,3 +71,5 @@ FEWO_BANK_ACCOUNT_HOLDER=
FEWO_BANK_IBAN=
FEWO_BANK_BIC=
FEWO_BANK_NAME=
FEWO_REVIEW_REQUEST_AFTER_DAYS=2
FEWO_GUEST_RETENTION_YEARS=10
+26
View File
@@ -0,0 +1,26 @@
<?php
namespace App\Actions;
use App\Models\Guest;
/**
* Anonymises guests whose last stay ended longer ago than the retention period (GDPR storage limitation).
*/
class AnonymizeGuests
{
public function handle(): int
{
$cutoff = today()->subYears(config('fewo.guest_retention_years'));
$guests = Guest::query()
->whereNull('anonymized_at')
->whereDate('created_at', '<', $cutoff)
->whereDoesntHave('bookings', fn ($query) => $query->whereDate('departure', '>=', $cutoff))
->get();
$guests->each->anonymize();
return $guests->count();
}
}
+22
View File
@@ -0,0 +1,22 @@
<?php
namespace App\Actions;
use App\Mail\MarketingConsentRequest;
use App\Models\Guest;
use Illuminate\Support\Facades\Mail;
/**
* First step of the double opt-in: the guest receives a confirmation link.
*/
class RequestMarketingConsent
{
public function handle(Guest $guest): void
{
if ($guest->marketing_consent_at !== null || $guest->anonymized_at !== null) {
return;
}
Mail::to($guest->email, $guest->full_name)->send(new MarketingConsentRequest($guest));
}
}
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Mail\ReviewRequest;
use App\Models\Booking;
use Illuminate\Support\Facades\Mail;
/**
* Sends the review invitation once, a few days after departure. Old stays (more than 30 days ago)
* are skipped so that switching the feature on does not mail former guests.
*/
class RequestReviews
{
public function handle(): int
{
$latestDeparture = today()->subDays(config('fewo.review_request_after_days'));
$bookings = Booking::query()
->whereIn('status', BookingStatus::occupying())
->whereNull('review_requested_at')
->whereDate('departure', '<=', $latestDeparture)
->whereDate('departure', '>', $latestDeparture->copy()->subDays(30))
->whereDoesntHave('review')
->whereHas('guest', fn ($query) => $query->whereNull('anonymized_at'))
->with('guest')
->get();
foreach ($bookings as $booking) {
Mail::to($booking->guest->email, $booking->guest->full_name)->send(new ReviewRequest($booking));
$booking->update(['review_requested_at' => now()]);
}
return $bookings->count();
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Actions;
use App\Enums\BookingStatus;
use App\Enums\ReviewStatus;
use App\Mail\NewReview;
use App\Models\Booking;
use App\Models\Review;
use Illuminate\Support\Facades\Mail;
use RuntimeException;
/**
* Stores a review written by a guest of a real, finished stay. It is published only after approval.
*/
class SubmitReview
{
/**
* @param array{rating: int, rating_cleanliness?: ?int, rating_equipment?: ?int, rating_location?: ?int, rating_host?: ?int, title?: ?string, body?: ?string, private_feedback?: ?string, display_name: string, publish_consent: bool} $data
*/
public function handle(Booking $booking, array $data): Review
{
if (! self::canReview($booking)) {
throw new RuntimeException('Für diese Buchung kann keine Bewertung abgegeben werden.');
}
$review = $booking->review()->create([
...$data,
'property_id' => $booking->property_id,
'status' => ReviewStatus::Pending,
'source' => 'website',
'stayed_on' => $booking->arrival,
]);
Mail::to(config('fewo.notification_email'))->send(new NewReview($review));
return $review;
}
public static function canReview(Booking $booking): bool
{
return in_array($booking->status, BookingStatus::occupying(), true)
&& $booking->departure->lessThanOrEqualTo(today())
&& ! $booking->review()->exists();
}
}
+48
View File
@@ -0,0 +1,48 @@
<?php
namespace App\Console\Commands;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use App\Models\Property;
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
#[Signature('photos:import {directory : Folder with JPG/PNG/WebP files} {--category=apartment : apartment, outdoor or area}')]
#[Description('Import all images of a folder as website photos (e.g. when migrating from the old website)')]
class ImportPhotos extends Command
{
/**
* Execute the console command.
*/
public function handle(): int
{
$category = PhotoCategory::tryFrom((string) $this->option('category'));
if ($category === null) {
$this->error('Unbekannte Kategorie. Erlaubt: '.implode(', ', array_column(PhotoCategory::cases(), 'value')));
return self::FAILURE;
}
$files = glob(rtrim((string) $this->argument('directory'), '/\\').'/*.{jpg,jpeg,png,webp,JPG,JPEG,PNG,WEBP}', GLOB_BRACE) ?: [];
$propertyId = $category === PhotoCategory::Area ? null : Property::query()->value('id');
$sort = (int) Photo::max('sort_order');
foreach ($files as $file) {
$photo = Photo::create([
'property_id' => $propertyId,
'category' => $category,
'alt_text' => str(pathinfo($file, PATHINFO_FILENAME))->replace(['_', '-'], ' ')->squish()->ucfirst()->toString(),
'sort_order' => ++$sort,
]);
$photo->addMedia($file)->preservingOriginal()->toMediaCollection(Photo::COLLECTION);
$this->line("✓ {$photo->alt_text}");
}
$this->info(count($files).' Bilder importiert.');
return self::SUCCESS;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum AmenityArea: string implements HasLabel
{
case General = 'general';
case LivingRoom = 'living_room';
case Bedroom = 'bedroom';
case Kitchen = 'kitchen';
case Bathroom = 'bathroom';
case Outdoor = 'outdoor';
public function getLabel(): string
{
return match ($this) {
self::General => 'Allgemein',
self::LivingRoom => 'Wohnzimmer',
self::Bedroom => 'Schlafzimmer',
self::Kitchen => 'Küche',
self::Bathroom => 'Bad',
self::Outdoor => 'Terrasse & Außenbereich',
};
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
enum NoticeTone: string implements HasColor, HasLabel
{
case Info = 'info';
case Offer = 'offer';
case Important = 'important';
public function getLabel(): string
{
return match ($this) {
self::Info => 'Information',
self::Offer => 'Angebot',
self::Important => 'Wichtig',
};
}
public function getColor(): string
{
return match ($this) {
self::Info => 'info',
self::Offer => 'success',
self::Important => 'warning',
};
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasLabel;
enum PhotoCategory: string implements HasLabel
{
case Apartment = 'apartment';
case Outdoor = 'outdoor';
case Area = 'area';
public function getLabel(): string
{
return match ($this) {
self::Apartment => 'Wohnung',
self::Outdoor => 'Terrasse & Garten',
self::Area => 'Kühlungsborn & Umgebung',
};
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;
enum ReviewStatus: string implements HasColor, HasLabel
{
case Pending = 'pending';
case Approved = 'approved';
case Rejected = 'rejected';
public function getLabel(): string
{
return match ($this) {
self::Pending => 'Zu prüfen',
self::Approved => 'Freigegeben',
self::Rejected => 'Abgelehnt',
};
}
public function getColor(): string
{
return match ($this) {
self::Pending => 'warning',
self::Approved => 'success',
self::Rejected => 'gray',
};
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
namespace App\Enums;
use Filament\Support\Contracts\HasDescription;
use Filament\Support\Contracts\HasLabel;
enum UserRole: string implements HasDescription, HasLabel
{
case Admin = 'admin';
case Rentals = 'rentals';
case Content = 'content';
public function getLabel(): string
{
return match ($this) {
self::Admin => 'Administrator',
self::Rentals => 'Vermietung',
self::Content => 'Inhalte',
};
}
public function getDescription(): string
{
return match ($this) {
self::Admin => 'Alles, inklusive Benutzerverwaltung',
self::Rentals => 'Buchungen, Gäste, Preise, Angebote und Bewertungen',
self::Content => 'Bilder, Texte, FAQ, Hinweise und Bewertungen',
};
}
}
+140
View File
@@ -0,0 +1,140 @@
<?php
namespace App\Filament\Pages;
use App\Enums\UserRole;
use App\Models\Photo;
use App\Support\Content;
use BackedEnum;
use Filament\Actions\Action;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Page;
use Filament\Schemas\Components\Actions;
use Filament\Schemas\Components\EmbeddedSchema;
use Filament\Schemas\Components\Form;
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Tabs\Tab;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use UnitEnum;
/**
* One form for all editable website texts from config/content.php, one tab per section.
*
* @property-read Schema $form
*/
class EditContent extends Page
{
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPencilSquare;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $navigationLabel = 'Texte';
protected static ?string $title = 'Webseiten-Texte';
protected static ?string $slug = 'texte';
protected static ?int $navigationSort = 2;
/** @var array<string, ?string> */
public array $data = [];
public static function canAccess(): bool
{
return (bool) auth()->user()?->hasRole(UserRole::Admin, UserRole::Content);
}
public function mount(): void
{
$values = [];
foreach (Content::sections() as $section) {
foreach (array_keys($section['fields']) as $key) {
$values[self::fieldName($key)] = Content::get($key);
}
}
$this->form->fill($values);
}
public function form(Schema $schema): Schema
{
return $schema
->statePath('data')
->components([
Tabs::make('sections')
->persistTabInQueryString()
->tabs(collect(Content::sections())
->map(fn (array $section): Tab => Tab::make($section['label'])->schema(
collect($section['fields'])->map(fn (array $field, string $key) => $this->field($key, $field))->values()->all(),
))
->values()
->all()),
]);
}
public function content(Schema $schema): Schema
{
return $schema->components([
Form::make([EmbeddedSchema::make('form')])
->id('form')
->livewireSubmitHandler('save')
->footer([
Actions::make([
Action::make('save')->label('Speichern')->submit('save')->keyBindings(['mod+s']),
])->sticky(),
]),
]);
}
public function save(): void
{
$state = $this->form->getState();
$values = [];
foreach (Content::sections() as $section) {
foreach (array_keys($section['fields']) as $key) {
$value = $state[self::fieldName($key)] ?? null;
$values[$key] = $value === null ? null : (string) $value;
}
}
Content::save($values);
Notification::make()->title('Texte gespeichert')->success()->send();
}
/**
* @param array{label: string, type: string, default?: ?string} $field
*/
private function field(string $key, array $field): TextInput|Textarea|RichEditor|Select
{
$name = self::fieldName($key);
return match ($field['type']) {
'textarea' => Textarea::make($name)->label($field['label'])->rows(3),
'richtext' => RichEditor::make($name)
->label($field['label'])
->toolbarButtons([['bold', 'italic', 'link'], ['h2', 'h3'], ['bulletList', 'orderedList'], ['undo', 'redo']]),
'photo' => Select::make($name)
->label($field['label'])
->options(fn (): array => Photo::query()->orderBy('category')->orderBy('sort_order')->pluck('alt_text', 'id')->all())
->searchable()
->placeholder('Kein Bild gewählt')
->helperText('Bilder verwalten Sie unter „Webseite › Bilder“.'),
default => TextInput::make($name)->label($field['label'])->maxLength(255),
};
}
/**
* Dots would be read as nested state, so content keys are flattened for the form.
*/
private static function fieldName(string $key): string
{
return str_replace('.', '__', $key);
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Resources\Amenities;
use App\Filament\Resources\Amenities\Pages\CreateAmenity;
use App\Filament\Resources\Amenities\Pages\EditAmenity;
use App\Filament\Resources\Amenities\Pages\ListAmenities;
use App\Filament\Resources\Amenities\Schemas\AmenityForm;
use App\Filament\Resources\Amenities\Tables\AmenitiesTable;
use App\Models\Amenity;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class AmenityResource extends Resource
{
protected static ?string $model = Amenity::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedListBullet;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Ausstattungsmerkmal';
protected static ?string $pluralModelLabel = 'Ausstattung';
protected static ?int $navigationSort = 3;
public static function form(Schema $schema): Schema
{
return AmenityForm::configure($schema);
}
public static function table(Table $table): Table
{
return AmenitiesTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListAmenities::route('/'),
'create' => CreateAmenity::route('/create'),
'edit' => EditAmenity::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Amenities\Pages;
use App\Filament\Resources\Amenities\AmenityResource;
use Filament\Resources\Pages\CreateRecord;
class CreateAmenity extends CreateRecord
{
protected static string $resource = AmenityResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Amenities\Pages;
use App\Filament\Resources\Amenities\AmenityResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditAmenity extends EditRecord
{
protected static string $resource = AmenityResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Amenities\Pages;
use App\Filament\Resources\Amenities\AmenityResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListAmenities extends ListRecords
{
protected static string $resource = AmenityResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Filament\Resources\Amenities\Schemas;
use App\Enums\AmenityArea;
use App\Models\Property;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
class AmenityForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
TextInput::make('name')
->label('Ausstattung')
->placeholder('z. B. Geschirrspüler')
->required()
->maxLength(255),
Select::make('area')
->label('Bereich')
->options(AmenityArea::class)
->required(),
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => Property::query()->value('id'))
->required(),
Toggle::make('is_highlight')
->label('Highlight (auf der Startseite hervorheben)'),
]);
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Filament\Resources\Amenities\Tables;
use App\Enums\AmenityArea;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Grouping\Group;
use Filament\Tables\Table;
class AmenitiesTable
{
public static function configure(Table $table): Table
{
return $table
->reorderable('sort_order')
->defaultSort('sort_order')
->defaultGroup(Group::make('area')->label('Bereich')->getTitleFromRecordUsing(fn ($record): string => $record->area->getLabel()))
->paginated(false)
->columns([
TextColumn::make('name')->label('Ausstattung')->searchable(),
ToggleColumn::make('is_highlight')->label('Highlight'),
])
->filters([
SelectFilter::make('area')->label('Bereich')->options(AmenityArea::class),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
}
@@ -15,6 +15,7 @@
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class BookingResource extends Resource
{
@@ -22,6 +23,8 @@ class BookingResource extends Resource
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCalendarDays;
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
protected static ?string $modelLabel = 'Buchung';
protected static ?string $pluralModelLabel = 'Anfragen & Buchungen';
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Resources\Faqs;
use App\Filament\Resources\Faqs\Pages\CreateFaq;
use App\Filament\Resources\Faqs\Pages\EditFaq;
use App\Filament\Resources\Faqs\Pages\ListFaqs;
use App\Filament\Resources\Faqs\Schemas\FaqForm;
use App\Filament\Resources\Faqs\Tables\FaqsTable;
use App\Models\Faq;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class FaqResource extends Resource
{
protected static ?string $model = Faq::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedQuestionMarkCircle;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Frage';
protected static ?string $pluralModelLabel = 'Häufige Fragen';
protected static ?int $navigationSort = 4;
public static function form(Schema $schema): Schema
{
return FaqForm::configure($schema);
}
public static function table(Table $table): Table
{
return FaqsTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListFaqs::route('/'),
'create' => CreateFaq::route('/create'),
'edit' => EditFaq::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Faqs\Pages;
use App\Filament\Resources\Faqs\FaqResource;
use Filament\Resources\Pages\CreateRecord;
class CreateFaq extends CreateRecord
{
protected static string $resource = FaqResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Faqs\Pages;
use App\Filament\Resources\Faqs\FaqResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditFaq extends EditRecord
{
protected static string $resource = FaqResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Faqs\Pages;
use App\Filament\Resources\Faqs\FaqResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListFaqs extends ListRecords
{
protected static string $resource = FaqResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,31 @@
<?php
namespace App\Filament\Resources\Faqs\Schemas;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
class FaqForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
TextInput::make('question')
->label('Frage')
->required()
->maxLength(255)
->columnSpanFull(),
RichEditor::make('answer')
->label('Antwort')
->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList']])
->required()
->columnSpanFull(),
Toggle::make('is_published')
->label('Veröffentlicht')
->default(true),
]);
}
}
@@ -0,0 +1,28 @@
<?php
namespace App\Filament\Resources\Faqs\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Table;
class FaqsTable
{
public static function configure(Table $table): Table
{
return $table
->reorderable('sort_order')
->defaultSort('sort_order')
->paginated(false)
->columns([
TextColumn::make('question')->label('Frage')->searchable()->wrap(),
ToggleColumn::make('is_published')->label('Veröffentlicht'),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
}
@@ -5,6 +5,7 @@
use App\Filament\Resources\Guests\Pages\CreateGuest;
use App\Filament\Resources\Guests\Pages\EditGuest;
use App\Filament\Resources\Guests\Pages\ListGuests;
use App\Filament\Resources\Guests\RelationManagers\BookingsRelationManager;
use App\Filament\Resources\Guests\Schemas\GuestForm;
use App\Filament\Resources\Guests\Tables\GuestsTable;
use App\Models\Guest;
@@ -13,6 +14,7 @@
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class GuestResource extends Resource
{
@@ -20,6 +22,8 @@ class GuestResource extends Resource
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUsers;
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
protected static ?string $modelLabel = 'Gast';
protected static ?string $pluralModelLabel = 'Gäste';
@@ -41,7 +45,7 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
BookingsRelationManager::class,
];
}
@@ -2,10 +2,17 @@
namespace App\Filament\Resources\Guests\Pages;
use App\Enums\UserRole;
use App\Filament\Resources\Guests\GuestResource;
use Filament\Actions\DeleteAction;
use App\Models\Guest;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Filament\Support\Icons\Heroicon;
/**
* @property Guest $record
*/
class EditGuest extends EditRecord
{
protected static string $resource = GuestResource::class;
@@ -13,7 +20,19 @@ class EditGuest extends EditRecord
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
Action::make('anonymize')
->label('Anonymisieren')
->icon(Heroicon::OutlinedEyeSlash)
->color('danger')
->visible(fn (): bool => $this->record->anonymized_at === null && (bool) auth()->user()?->hasRole(UserRole::Admin))
->requiresConfirmation()
->modalDescription('Name, Kontaktdaten, Notizen und Nachrichten werden unwiderruflich entfernt (z. B. auf Löschwunsch nach DSGVO). Buchungen und Beträge bleiben für die Buchhaltung erhalten.')
->action(function (): void {
$this->record->anonymize();
$this->refreshFormData(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'notes', 'tags']);
Notification::make()->title('Gast anonymisiert')->success()->send();
}),
];
}
}
@@ -3,8 +3,13 @@
namespace App\Filament\Resources\Guests\Pages;
use App\Filament\Resources\Guests\GuestResource;
use App\Models\Guest;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Symfony\Component\HttpFoundation\StreamedResponse;
class ListGuests extends ListRecords
{
@@ -13,7 +18,52 @@ class ListGuests extends ListRecords
protected function getHeaderActions(): array
{
return [
Action::make('export')
->label('Export (Excel/CSV)')
->icon(Heroicon::OutlinedArrowDownTray)
->color('gray')
->schema([
Toggle::make('consent_only')->label('Nur Gäste mit Einwilligung für Angebote'),
])
->action(fn (array $data): StreamedResponse => $this->export($data['consent_only'])),
CreateAction::make(),
];
}
/**
* Semicolon-separated UTF-8 with BOM so that Excel opens umlauts correctly.
*/
private function export(bool $consentOnly): StreamedResponse
{
$guests = Guest::query()
->whereNull('anonymized_at')
->when($consentOnly, fn ($query) => $query->withMarketingConsent())
->withCount('bookings')
->orderBy('last_name')
->get();
return response()->streamDownload(function () use ($guests): void {
$out = fopen('php://output', 'w');
fwrite($out, "\xEF\xBB\xBF");
fputcsv($out, ['Vorname', 'Nachname', 'E-Mail', 'Telefon', 'Straße', 'PLZ', 'Ort', 'Land', 'Markierungen', 'Buchungen', 'Einwilligung Angebote'], ';');
foreach ($guests as $guest) {
fputcsv($out, [
$guest->first_name,
$guest->last_name,
$guest->email,
$guest->phone,
$guest->street,
$guest->postal_code,
$guest->city,
$guest->country,
implode(', ', $guest->tags ?? []),
$guest->bookings_count,
$guest->marketing_consent_at?->format('d.m.Y'),
], ';');
}
fclose($out);
}, 'gaeste-'.now()->format('Y-m-d').'.csv', ['Content-Type' => 'text/csv; charset=UTF-8']);
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Filament\Resources\Guests\RelationManagers;
use App\Filament\Resources\Bookings\BookingResource;
use App\Models\Booking;
use Filament\Actions\ViewAction;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class BookingsRelationManager extends RelationManager
{
protected static string $relationship = 'bookings';
protected static ?string $title = 'Aufenthalte & Anfragen';
public function isReadOnly(): bool
{
return true;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('reference')
->columns([
TextColumn::make('reference')->label('Nr.'),
TextColumn::make('arrival')->label('Anreise')->date('d.m.Y'),
TextColumn::make('departure')->label('Abreise')->date('d.m.Y'),
TextColumn::make('guests')->label('Pers.'),
TextColumn::make('status')->label('Status')->badge(),
TextColumn::make('total')->label('Gesamt')->money('EUR', divideBy: 100, locale: 'de'),
])
->recordActions([
ViewAction::make()->url(fn (Booking $record): string => BookingResource::getUrl('view', ['record' => $record])),
]);
}
}
@@ -2,9 +2,13 @@
namespace App\Filament\Resources\Guests\Schemas;
use App\Models\Guest;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Infolists\Components\TextEntry;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class GuestForm
@@ -12,21 +16,40 @@ class GuestForm
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->columns(3)
->components([
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
TextInput::make('last_name')->label('Nachname')->required()->maxLength(255),
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
TextInput::make('phone')->label('Telefon')->tel()->maxLength(50),
TextInput::make('street')->label('Straße')->maxLength(255),
TextInput::make('postal_code')->label('PLZ')->maxLength(20),
TextInput::make('city')->label('Ort')->maxLength(255),
Select::make('country')
->label('Land')
->options(['DE' => 'Deutschland', 'AT' => 'Österreich', 'CH' => 'Schweiz', 'NL' => 'Niederlande', 'DK' => 'Dänemark', 'PL' => 'Polen'])
->default('DE')
->required(),
Textarea::make('notes')->label('Notizen')->columnSpanFull(),
Section::make('Kontakt')
->columnSpan(2)
->columns(2)
->schema([
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
TextInput::make('last_name')->label('Nachname')->required()->maxLength(255),
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
TextInput::make('phone')->label('Telefon')->tel()->maxLength(50),
TextInput::make('street')->label('Straße')->maxLength(255),
TextInput::make('postal_code')->label('PLZ')->maxLength(20),
TextInput::make('city')->label('Ort')->maxLength(255),
Select::make('country')
->label('Land')
->options(['DE' => 'Deutschland', 'AT' => 'Österreich', 'CH' => 'Schweiz', 'NL' => 'Niederlande', 'DK' => 'Dänemark', 'PL' => 'Polen'])
->default('DE')
->required(),
]),
Section::make('Verwaltung')
->columnSpan(1)
->schema([
TagsInput::make('tags')
->label('Markierungen')
->suggestions(['Stammgast', 'Familie', 'Empfehlung', 'Nicht wieder vermieten']),
TextEntry::make('marketing_consent_at')
->label('Einwilligung Angebote per E-Mail')
->state(fn (?Guest $record): string => $record?->marketing_consent_at ? 'bestätigt am '.$record->marketing_consent_at->format('d.m.Y') : 'keine'),
TextEntry::make('anonymized_at')
->label('Anonymisiert')
->dateTime('d.m.Y')
->visible(fn (?Guest $record): bool => $record?->anonymized_at !== null),
Textarea::make('notes')->label('Notizen')->rows(5),
]),
]);
}
}
@@ -2,28 +2,54 @@
namespace App\Filament\Resources\Guests\Tables;
use App\Enums\BookingStatus;
use App\Models\Guest;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class GuestsTable
{
public static function configure(Table $table): Table
{
$countedBookings = ['bookings' => fn (Builder $query): Builder => $query->whereIn('status', BookingStatus::occupying())];
return $table
->defaultSort('last_name')
->columns([
TextColumn::make('last_name')
->label('Name')
->formatStateUsing(fn (Guest $record): string => "{$record->last_name}, {$record->first_name}")
->searchable(['first_name', 'last_name'])
->description(fn (Guest $record): string => $record->email)
->searchable(['first_name', 'last_name', 'email'])
->sortable(),
TextColumn::make('email')->label('E-Mail')->searchable(),
TextColumn::make('phone')->label('Telefon')->placeholder('–'),
TextColumn::make('city')->label('Ort')->placeholder('–'),
TextColumn::make('bookings_count')->label('Buchungen')->counts('bookings')->sortable(),
TextColumn::make('created_at')->label('Seit')->date('m/Y')->sortable(),
TextColumn::make('city')->label('Ort')->placeholder('–')->toggleable(),
TextColumn::make('tags')->label('Markierungen')->badge(),
TextColumn::make('bookings_count')->label('Aufenthalte')->counts($countedBookings)->sortable(),
TextColumn::make('bookings_sum_total')->label('Umsatz')->sum($countedBookings, 'total')->money('EUR', divideBy: 100, locale: 'de')->sortable(),
IconColumn::make('marketing_consent_at')->label('Angebote')->boolean()->getStateUsing(fn (Guest $record): bool => $record->marketing_consent_at !== null),
])
->filters([
Filter::make('returning')
->label('Stammgäste (ab 2 Aufenthalten)')
->query(fn (Builder $query): Builder => $query->has('bookings', '>=', 2)),
TernaryFilter::make('marketing_consent_at')
->label('Einwilligung Angebote')
->nullable(),
SelectFilter::make('tag')
->label('Markierung')
->options(fn (): array => Guest::query()->whereNotNull('tags')->pluck('tags')->flatten()->unique()->sort()->mapWithKeys(fn (string $tag): array => [$tag => $tag])->all())
->query(fn (Builder $query, array $data): Builder => $query->when($data['value'], fn (Builder $query, string $tag): Builder => $query->whereJsonContains('tags', $tag))),
TernaryFilter::make('anonymized_at')
->label('Anonymisierte anzeigen')
->nullable()
->default(false),
])
->recordActions([
EditAction::make(),
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Resources\Notices;
use App\Filament\Resources\Notices\Pages\CreateNotice;
use App\Filament\Resources\Notices\Pages\EditNotice;
use App\Filament\Resources\Notices\Pages\ListNotices;
use App\Filament\Resources\Notices\Schemas\NoticeForm;
use App\Filament\Resources\Notices\Tables\NoticesTable;
use App\Models\Notice;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class NoticeResource extends Resource
{
protected static ?string $model = Notice::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMegaphone;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Hinweis';
protected static ?string $pluralModelLabel = 'Hinweis-Banner';
protected static ?int $navigationSort = 5;
public static function form(Schema $schema): Schema
{
return NoticeForm::configure($schema);
}
public static function table(Table $table): Table
{
return NoticesTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListNotices::route('/'),
'create' => CreateNotice::route('/create'),
'edit' => EditNotice::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Notices\Pages;
use App\Filament\Resources\Notices\NoticeResource;
use Filament\Resources\Pages\CreateRecord;
class CreateNotice extends CreateRecord
{
protected static string $resource = NoticeResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Notices\Pages;
use App\Filament\Resources\Notices\NoticeResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditNotice extends EditRecord
{
protected static string $resource = NoticeResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Notices\Pages;
use App\Filament\Resources\Notices\NoticeResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListNotices extends ListRecords
{
protected static string $resource = NoticeResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,49 @@
<?php
namespace App\Filament\Resources\Notices\Schemas;
use App\Enums\NoticeTone;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
class NoticeForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
TextInput::make('text')
->label('Hinweistext')
->placeholder('z. B. Kurzfristig frei: 12.–15.11. mit 15 % Rabatt')
->required()
->maxLength(255)
->columnSpanFull(),
Select::make('tone')
->label('Art')
->options(NoticeTone::class)
->default(NoticeTone::Info)
->required(),
Toggle::make('is_active')
->label('Aktiv')
->default(true)
->inline(false),
DatePicker::make('starts_on')
->label('Anzeigen ab (optional)'),
DatePicker::make('ends_on')
->label('Anzeigen bis (optional)')
->afterOrEqual('starts_on'),
TextInput::make('link_label')
->label('Link-Text (optional)')
->placeholder('z. B. Jetzt anfragen')
->maxLength(100),
TextInput::make('link_url')
->label('Link-Ziel (optional)')
->placeholder('/buchen')
->maxLength(255),
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Filament\Resources\Notices\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Table;
class NoticesTable
{
public static function configure(Table $table): Table
{
return $table
->defaultSort('starts_on', 'desc')
->columns([
TextColumn::make('text')->label('Hinweis')->wrap()->searchable(),
TextColumn::make('tone')->label('Art')->badge(),
TextColumn::make('starts_on')->label('Ab')->date('d.m.Y')->placeholder('sofort'),
TextColumn::make('ends_on')->label('Bis')->date('d.m.Y')->placeholder('unbegrenzt'),
ToggleColumn::make('is_active')->label('Aktiv'),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Filament\Resources\Photos\PhotoResource;
use Filament\Resources\Pages\CreateRecord;
class CreatePhoto extends CreateRecord
{
protected static string $resource = PhotoResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Filament\Resources\Photos\PhotoResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditPhoto extends EditRecord
{
protected static string $resource = PhotoResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,66 @@
<?php
namespace App\Filament\Resources\Photos\Pages;
use App\Enums\PhotoCategory;
use App\Filament\Resources\Photos\PhotoResource;
use App\Models\Photo;
use App\Models\Property;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Select;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
class ListPhotos extends ListRecords
{
protected static string $resource = PhotoResource::class;
protected function getHeaderActions(): array
{
return [
Action::make('bulkUpload')
->label('Mehrere Bilder hochladen')
->icon(Heroicon::OutlinedArrowUpTray)
->authorize('create', Photo::class)
->modalDescription('Die Bildbeschreibung wird aus dem Dateinamen vorbelegt – bitte danach kurz anpassen.')
->schema([
FileUpload::make('files')
->label('Bilder')
->multiple()
->image()
->maxSize(25 * 1024)
->storeFiles(false)
->required(),
Select::make('category')
->label('Kategorie')
->options(PhotoCategory::class)
->default(PhotoCategory::Apartment)
->required(),
])
->action(function (array $data): void {
$propertyId = Property::query()->value('id');
$nextSort = (int) Photo::max('sort_order');
/** @var TemporaryUploadedFile $file */
foreach ($data['files'] as $file) {
$photo = Photo::create([
'property_id' => $data['category'] === PhotoCategory::Area->value ? null : $propertyId,
'category' => $data['category'],
'alt_text' => str(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME))->replace(['_', '-'], ' ')->squish()->ucfirst()->toString(),
'sort_order' => ++$nextSort,
]);
$photo->addMedia($file->getRealPath())
->usingFileName($file->getClientOriginalName())
->toMediaCollection(Photo::COLLECTION);
}
Notification::make()->title(count($data['files']).' Bilder hochgeladen')->success()->send();
}),
CreateAction::make()->label('Einzelnes Bild'),
];
}
}
@@ -0,0 +1,57 @@
<?php
namespace App\Filament\Resources\Photos;
use App\Filament\Resources\Photos\Pages\CreatePhoto;
use App\Filament\Resources\Photos\Pages\EditPhoto;
use App\Filament\Resources\Photos\Pages\ListPhotos;
use App\Filament\Resources\Photos\Schemas\PhotoForm;
use App\Filament\Resources\Photos\Tables\PhotosTable;
use App\Models\Photo;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class PhotoResource extends Resource
{
protected static ?string $model = Photo::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPhoto;
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
protected static ?string $modelLabel = 'Bild';
protected static ?string $pluralModelLabel = 'Bilder';
protected static ?int $navigationSort = 1;
public static function form(Schema $schema): Schema
{
return PhotoForm::configure($schema);
}
public static function table(Table $table): Table
{
return PhotosTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListPhotos::route('/'),
'create' => CreatePhoto::route('/create'),
'edit' => EditPhoto::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,53 @@
<?php
namespace App\Filament\Resources\Photos\Schemas;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use App\Models\Property;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Schema;
class PhotoForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
SpatieMediaLibraryFileUpload::make('image')
->label('Bild')
->collection(Photo::COLLECTION)
->image()
->imageEditor()
->maxSize(25 * 1024)
->helperText('JPG, PNG oder WebP bis 25 MB. Große Originale sind willkommen – Web-Größen werden automatisch erzeugt.')
->required()
->columnSpanFull(),
TextInput::make('alt_text')
->label('Bildbeschreibung')
->helperText('Kurz beschreiben, was zu sehen ist – wichtig für Google und für blinde Besucher.')
->required()
->maxLength(255),
TextInput::make('caption')
->label('Bildunterschrift (optional)')
->maxLength(255),
Select::make('category')
->label('Kategorie')
->options(PhotoCategory::class)
->default(PhotoCategory::Apartment)
->required(),
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => Property::query()->value('id'))
->placeholder('– keine (z. B. Umgebung) –'),
Toggle::make('is_published')
->label('Auf der Webseite zeigen')
->default(true),
]);
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Filament\Resources\Photos\Tables;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\Layout\Stack;
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
class PhotosTable
{
public static function configure(Table $table): Table
{
return $table
->reorderable('sort_order')
->defaultSort('sort_order')
->contentGrid(['md' => 3, 'xl' => 4])
->paginated([24, 48, 'all'])
->columns([
Stack::make([
SpatieMediaLibraryImageColumn::make('image')
->collection(Photo::COLLECTION)
->conversion('sm')
->imageHeight(180)
->extraImgAttributes(['class' => 'w-full object-cover rounded-lg']),
TextColumn::make('alt_text')
->weight('medium')
->searchable(),
TextColumn::make('category')
->badge(),
IconColumn::make('is_published')
->boolean()
->trueIcon('heroicon-o-eye')
->falseIcon('heroicon-o-eye-slash'),
])->space(2),
])
->filters([
SelectFilter::make('category')
->label('Kategorie')
->options(PhotoCategory::class),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
}
@@ -17,6 +17,7 @@
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class PropertyResource extends Resource
{
@@ -24,6 +25,8 @@ class PropertyResource extends Resource
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedHomeModern;
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
protected static ?string $modelLabel = 'Wohnung';
protected static ?string $pluralModelLabel = 'Wohnungen';
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Reviews\Pages;
use App\Filament\Resources\Reviews\ReviewResource;
use Filament\Resources\Pages\CreateRecord;
class CreateReview extends CreateRecord
{
protected static string $resource = ReviewResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Reviews\Pages;
use App\Filament\Resources\Reviews\ReviewResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditReview extends EditRecord
{
protected static string $resource = ReviewResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Reviews\Pages;
use App\Filament\Resources\Reviews\ReviewResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListReviews extends ListRecords
{
protected static string $resource = ReviewResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,70 @@
<?php
namespace App\Filament\Resources\Reviews;
use App\Enums\ReviewStatus;
use App\Filament\Resources\Reviews\Pages\CreateReview;
use App\Filament\Resources\Reviews\Pages\EditReview;
use App\Filament\Resources\Reviews\Pages\ListReviews;
use App\Filament\Resources\Reviews\Schemas\ReviewForm;
use App\Filament\Resources\Reviews\Tables\ReviewsTable;
use App\Models\Review;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class ReviewResource extends Resource
{
protected static ?string $model = Review::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedStar;
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
protected static ?string $modelLabel = 'Bewertung';
protected static ?string $pluralModelLabel = 'Bewertungen';
protected static ?int $navigationSort = 3;
public static function getNavigationBadge(): ?string
{
$pending = Review::query()->where('status', ReviewStatus::Pending)->count();
return $pending > 0 ? (string) $pending : null;
}
public static function getNavigationBadgeColor(): string
{
return 'warning';
}
public static function form(Schema $schema): Schema
{
return ReviewForm::configure($schema);
}
public static function table(Table $table): Table
{
return ReviewsTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListReviews::route('/'),
'create' => CreateReview::route('/create'),
'edit' => EditReview::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,67 @@
<?php
namespace App\Filament\Resources\Reviews\Schemas;
use App\Enums\ReviewStatus;
use App\Models\Property;
use App\Models\Review;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class ReviewForm
{
public static function configure(Schema $schema): Schema
{
$stars = [1 => '★', 2 => '★★', 3 => '★★★', 4 => '★★★★', 5 => '★★★★★'];
return $schema
->columns(3)
->components([
Section::make('Bewertung')
->columnSpan(2)
->columns(2)
->schema([
TextInput::make('display_name')->label('Angezeigter Name')->required()->maxLength(80),
DatePicker::make('stayed_on')->label('Aufenthalt'),
Select::make('rating')->label('Gesamt')->options($stars)->required(),
...collect(Review::CATEGORIES)->map(fn (string $label, string $field) => Select::make($field)->label($label)->options($stars))->values()->all(),
TextInput::make('title')->label('Überschrift')->maxLength(120)->columnSpanFull(),
Textarea::make('body')->label('Text')->rows(5)->columnSpanFull(),
Textarea::make('private_feedback')
->label('Nur für die Gastgeber')
->rows(3)
->disabled(fn (?Review $record): bool => $record?->source === 'website')
->columnSpanFull(),
]),
Section::make('Freigabe')
->columnSpan(1)
->schema([
Select::make('status')->label('Status')->options(ReviewStatus::class)->default(ReviewStatus::Approved)->required(),
Toggle::make('publish_consent')
->label('Gast hat Veröffentlichung erlaubt')
->disabled(fn (?Review $record): bool => $record?->source === 'website'),
TextInput::make('source')
->label('Quelle')
->helperText('„website“ = über den Bewertungslink. Bei übernommenen Bewertungen das Portal eintragen.')
->default('manuell')
->disabled(fn (?Review $record): bool => $record?->source === 'website')
->required(),
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => Property::query()->value('id'))
->required(),
]),
Section::make('Öffentliche Antwort der Gastgeber')
->columnSpanFull()
->schema([
Textarea::make('response')->hiddenLabel()->rows(3)->placeholder('Optional – erscheint unter der Bewertung.'),
]),
]);
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Filament\Resources\Reviews\Tables;
use App\Enums\ReviewStatus;
use App\Models\Review;
use Filament\Actions\Action;
use Filament\Actions\EditAction;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
class ReviewsTable
{
public static function configure(Table $table): Table
{
return $table
->defaultSort('created_at', 'desc')
->columns([
TextColumn::make('rating')
->label('Sterne')
->formatStateUsing(fn (int $state): string => str_repeat('★', $state).str_repeat('☆', 5 - $state))
->color('warning')
->sortable(),
TextColumn::make('display_name')
->label('Gast')
->description(fn (Review $record): ?string => $record->title)
->searchable(['display_name', 'title', 'body']),
TextColumn::make('status')->label('Status')->badge(),
IconColumn::make('publish_consent')->label('Darf veröffentlicht werden')->boolean(),
TextColumn::make('source')->label('Quelle'),
TextColumn::make('stayed_on')->label('Aufenthalt')->date('m/Y')->sortable(),
])
->filters([
SelectFilter::make('status')->label('Status')->options(ReviewStatus::class),
])
->recordActions([
Action::make('approve')
->label('Freigeben')
->icon(Heroicon::OutlinedCheck)
->color('success')
->visible(fn (Review $record): bool => $record->status !== ReviewStatus::Approved)
->action(fn (Review $record) => $record->update(['status' => ReviewStatus::Approved])),
Action::make('reject')
->label('Ablehnen')
->icon(Heroicon::OutlinedXMark)
->color('gray')
->visible(fn (Review $record): bool => $record->status === ReviewStatus::Pending)
->action(fn (Review $record) => $record->update(['status' => ReviewStatus::Rejected])),
EditAction::make(),
]);
}
}
@@ -0,0 +1,11 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Resources\Pages\CreateRecord;
class CreateUser extends CreateRecord
{
protected static string $resource = UserResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditUser extends EditRecord
{
protected static string $resource = UserResource::class;
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
];
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\Users\Pages;
use App\Filament\Resources\Users\UserResource;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
{
protected static string $resource = UserResource::class;
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
];
}
}
@@ -0,0 +1,41 @@
<?php
namespace App\Filament\Resources\Users\Schemas;
use App\Enums\UserRole;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;
class UserForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
TextInput::make('name')
->label('Name')
->required()
->maxLength(255),
TextInput::make('email')
->label('E-Mail (Anmeldename)')
->email()
->required()
->unique(ignoreRecord: true)
->maxLength(255),
Radio::make('role')
->label('Rolle')
->options(UserRole::class)
->required()
->columnSpanFull(),
TextInput::make('password')
->label(fn (string $operation): string => $operation === 'create' ? 'Passwort' : 'Neues Passwort (leer lassen = unverändert)')
->password()
->revealable()
->minLength(10)
->required(fn (string $operation): bool => $operation === 'create')
->dehydrated(fn (?string $state): bool => filled($state)),
]);
}
}
@@ -0,0 +1,25 @@
<?php
namespace App\Filament\Resources\Users\Tables;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class UsersTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('name')->label('Name')->searchable(),
TextColumn::make('email')->label('E-Mail')->searchable(),
TextColumn::make('role')->label('Rolle')->badge(),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
]);
}
}
@@ -0,0 +1,55 @@
<?php
namespace App\Filament\Resources\Users;
use App\Filament\Resources\Users\Pages\CreateUser;
use App\Filament\Resources\Users\Pages\EditUser;
use App\Filament\Resources\Users\Pages\ListUsers;
use App\Filament\Resources\Users\Schemas\UserForm;
use App\Filament\Resources\Users\Tables\UsersTable;
use App\Models\User;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use UnitEnum;
class UserResource extends Resource
{
protected static ?string $model = User::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUserGroup;
protected static string|UnitEnum|null $navigationGroup = 'System';
protected static ?string $modelLabel = 'Benutzer';
protected static ?string $pluralModelLabel = 'Benutzer';
public static function form(Schema $schema): Schema
{
return UserForm::configure($schema);
}
public static function table(Table $table): Table
{
return UsersTable::configure($table);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'edit' => EditUser::route('/{record}/edit'),
];
}
}
@@ -0,0 +1,37 @@
<?php
namespace App\Http\Controllers;
use App\Models\Guest;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\URL;
/**
* Double opt-in confirmation and unsubscribe for offer e-mails. Both links are signed.
*/
class MarketingConsentController extends Controller
{
public function confirm(Guest $guest): View
{
if ($guest->marketing_consent_at === null) {
$guest->forceFill(['marketing_consent_at' => now()])->save();
}
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),
]);
}
public function unsubscribe(Guest $guest): View
{
$guest->forceFill(['marketing_consent_at' => null])->save();
return view('marketing-consent', [
'title' => 'Abgemeldet',
'message' => 'Sie erhalten keine Angebote mehr per E-Mail. Informationen zu Ihren Buchungen senden wir Ihnen selbstverständlich weiterhin.',
'unsubscribeUrl' => null,
]);
}
}
+8
View File
@@ -3,6 +3,7 @@
namespace App\Livewire;
use App\Actions\CreateReservation;
use App\Actions\RequestMarketingConsent;
use App\Availability\AvailabilityChecker;
use App\Exceptions\ReservationException;
use App\Models\Booking;
@@ -62,6 +63,9 @@ class BookingRequest extends Component
public bool $privacyAccepted = false;
/** Optional opt-in for offer e-mails (confirmed by double opt-in). */
public bool $marketingOptIn = false;
/** Honeypot, must stay empty. */
public string $website = '';
@@ -232,6 +236,10 @@ public function submit(CreateReservation $createReservation): void
return;
}
if ($this->marketingOptIn) {
rescue(fn () => app(RequestMarketingConsent::class)->handle($booking->guest));
}
$this->bookingId = $booking->id;
}
+72
View File
@@ -0,0 +1,72 @@
<?php
namespace App\Livewire;
use App\Actions\SubmitReview;
use App\Models\Booking;
use App\Models\Review;
use Illuminate\Contracts\View\View;
use Livewire\Component;
/**
* Review form for a finished stay, reached through the signed link in the review invitation.
*/
class ReviewForm extends Component
{
public Booking $booking;
public int $rating = 0;
/** @var array<string, int> */
public array $categories = ['rating_cleanliness' => 0, 'rating_equipment' => 0, 'rating_location' => 0, 'rating_host' => 0];
public string $title = '';
public string $body = '';
public string $privateFeedback = '';
public string $displayName = '';
public bool $publishConsent = true;
public bool $submitted = false;
public function mount(Booking $booking): void
{
$this->booking = $booking;
$this->displayName = $booking->guest->first_name.' '.mb_substr($booking->guest->last_name, 0, 1).'.'.($booking->guest->city ? ' aus '.$booking->guest->city : '');
}
public function submit(SubmitReview $submitReview): void
{
$this->validate([
'rating' => ['required', 'integer', 'between:1,5'],
'categories.*' => ['integer', 'between:0,5'],
'title' => ['nullable', 'string', 'max:120'],
'body' => ['nullable', 'string', 'max:3000'],
'privateFeedback' => ['nullable', 'string', 'max:3000'],
'displayName' => ['required', 'string', 'max:80'],
], [], ['rating' => 'Gesamtbewertung', 'displayName' => 'Angezeigter Name']);
$submitReview->handle($this->booking, [
'rating' => $this->rating,
...array_map(fn (int $value): ?int => $value > 0 ? $value : null, $this->categories),
'title' => $this->title ?: null,
'body' => $this->body ?: null,
'private_feedback' => $this->privateFeedback ?: null,
'display_name' => $this->displayName,
'publish_consent' => $this->publishConsent,
]);
$this->submitted = true;
}
public function render(): View
{
return view('livewire.review-form', [
'canReview' => $this->submitted || SubmitReview::canReview($this->booking),
'categoryLabels' => Review::CATEGORIES,
]);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Mail;
use App\Models\Guest;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\URL;
/**
* Double opt-in: the guest confirms that they want to receive offers.
*/
class MarketingConsentRequest extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Guest $guest) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Bitte bestätigen: Angebote der Ferienwohnung Stommer',
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
);
}
public function content(): Content
{
return new Content(
with: ['url' => URL::temporarySignedRoute('marketing.confirm', now()->addDays(14), $this->guest)],
markdown: 'mail.marketing-consent-request',
);
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
namespace App\Mail;
use App\Models\Review;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
/**
* Notifies the landlord about a new review to approve.
*/
class NewReview extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Review $review) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Neue Bewertung: '.str_repeat('★', $this->review->rating).' von '.$this->review->display_name,
);
}
public function content(): Content
{
return new Content(
markdown: 'mail.new-review',
);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
namespace App\Mail;
use App\Models\Booking;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\URL;
/**
* Asks the guest for a review a few days after departure.
*/
class ReviewRequest extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public Booking $booking) {}
public function envelope(): Envelope
{
return new Envelope(
subject: 'Wie war Ihr Aufenthalt in Kühlungsborn?',
replyTo: [new Address(config('fewo.owner.email'), config('fewo.owner.name'))],
);
}
public function content(): Content
{
return new Content(
with: ['url' => URL::temporarySignedRoute('reviews.create', now()->addDays(90), $this->booking)],
markdown: 'mail.review-request',
);
}
}
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace App\Models;
use App\Enums\AmenityArea;
use Database\Factories\AmenityFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* One line of the equipment list; highlights are featured on the home page.
*/
#[Fillable(['property_id', 'area', 'name', 'is_highlight', 'sort_order'])]
class Amenity extends Model
{
/** @use HasFactory<AmenityFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'area' => AmenityArea::class,
'is_highlight' => 'boolean',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
}
+11
View File
@@ -11,6 +11,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* A reservation or booking. arrival is the first night, departure the day the guest leaves,
@@ -35,6 +36,7 @@
'internal_notes',
'confirmed_at',
'cancelled_at',
'review_requested_at',
])]
class Booking extends Model
{
@@ -65,6 +67,7 @@ protected function casts(): array
'hold_expires_at' => 'immutable_datetime',
'confirmed_at' => 'immutable_datetime',
'cancelled_at' => 'immutable_datetime',
'review_requested_at' => 'immutable_datetime',
];
}
@@ -112,6 +115,14 @@ protected function overlapping(Builder $query, CarbonInterface $from, CarbonInte
->whereDate('departure', '>', $from);
}
/**
* @return HasOne<Review, $this>
*/
public function review(): HasOne
{
return $this->hasOne(Review::class);
}
public function nights(): int
{
return (int) $this->arrival->diffInDays($this->departure);
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
/**
* Value of an editable website text; the available keys are defined in config/content.php.
*/
#[Fillable(['key', 'value'])]
class ContentBlock extends Model {}
+39
View File
@@ -0,0 +1,39 @@
<?php
namespace App\Models;
use Database\Factories\FaqFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
#[Fillable(['question', 'answer', 'is_published', 'sort_order'])]
class Faq extends Model
{
/** @use HasFactory<FaqFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'is_published' => 'boolean',
];
}
/**
* @param Builder<Faq> $query
* @return Builder<Faq>
*/
#[Scope]
protected function published(Builder $query): Builder
{
return $query->where('is_published', true)->orderBy('sort_order');
}
}
+54 -1
View File
@@ -4,18 +4,35 @@
use Database\Factories\GuestFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country', 'locale', 'notes'])]
#[Fillable(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'country', 'locale', 'notes', 'tags'])]
class Guest extends Model
{
/** @use HasFactory<GuestFactory> */
use HasFactory, Notifiable;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'tags' => 'array',
'marketing_consent_at' => 'immutable_datetime',
'anonymized_at' => 'immutable_datetime',
];
}
/**
* @return HasMany<Booking, $this>
*/
@@ -31,4 +48,40 @@ protected function fullName(): Attribute
{
return Attribute::get(fn (): string => "{$this->first_name} {$this->last_name}");
}
/**
* Guests who confirmed (double opt-in) that they want to receive offers by e-mail.
*
* @param Builder<Guest> $query
* @return Builder<Guest>
*/
#[Scope]
protected function withMarketingConsent(Builder $query): Builder
{
return $query->whereNotNull('marketing_consent_at')->whereNull('anonymized_at');
}
/**
* Removes all personal data (GDPR). Bookings stay for accounting, without personal messages.
*/
public function anonymize(): void
{
DB::transaction(function (): void {
$this->bookings()->update(['message' => null]);
$this->forceFill([
'first_name' => 'Anonymisiert',
'last_name' => "#{$this->id}",
'email' => "anonymisiert-{$this->id}@invalid.local",
'phone' => null,
'street' => null,
'postal_code' => null,
'city' => null,
'notes' => null,
'tags' => null,
'marketing_consent_at' => null,
'anonymized_at' => now(),
])->save();
});
}
}
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Models;
use App\Enums\NoticeTone;
use Database\Factories\NoticeFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* A banner shown on the website, optionally limited to a date range.
*/
#[Fillable(['text', 'tone', 'link_url', 'link_label', 'starts_on', 'ends_on', 'is_active'])]
class Notice extends Model
{
/** @use HasFactory<NoticeFactory> */
use HasFactory;
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'tone' => NoticeTone::class,
'starts_on' => 'immutable_date',
'ends_on' => 'immutable_date',
'is_active' => 'boolean',
];
}
/**
* Active notices whose date range includes today.
*
* @param Builder<Notice> $query
* @return Builder<Notice>
*/
#[Scope]
protected function visible(Builder $query): Builder
{
return $query
->where('is_active', true)
->where(fn (Builder $query) => $query->whereNull('starts_on')->orWhereDate('starts_on', '<=', today()))
->where(fn (Builder $query) => $query->whereNull('ends_on')->orWhereDate('ends_on', '>=', today()));
}
}
+95
View File
@@ -0,0 +1,95 @@
<?php
namespace App\Models;
use App\Enums\PhotoCategory;
use Database\Factories\PhotoFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\Image\Enums\Fit;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
/**
* A website photo. The uploaded original is kept; web sizes are generated as WebP on upload.
*/
#[Fillable(['property_id', 'category', 'alt_text', 'caption', 'is_published', 'sort_order'])]
class Photo extends Model implements HasMedia
{
/** @use HasFactory<PhotoFactory> */
use HasFactory, InteractsWithMedia;
public const COLLECTION = 'image';
/** Generated widths in px, used for srcset. */
public const WIDTHS = ['sm' => 640, 'md' => 1280, 'lg' => 2048];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'category' => PhotoCategory::class,
'is_published' => 'boolean',
];
}
public function registerMediaCollections(): void
{
$this->addMediaCollection(self::COLLECTION)
->singleFile()
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
}
public function registerMediaConversions(?Media $media = null): void
{
foreach (self::WIDTHS as $name => $width) {
$this->addMediaConversion($name)
->fit(Fit::Max, $width, $width)
->format('webp')
->quality(80)
->performOnCollections(self::COLLECTION);
}
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @param Builder<Photo> $query
* @return Builder<Photo>
*/
#[Scope]
protected function published(Builder $query): Builder
{
return $query->where('is_published', true)->orderBy('sort_order');
}
public function url(string $size = 'md'): string
{
return $this->getFirstMediaUrl(self::COLLECTION, $size);
}
/**
* srcset for <img>, e.g. "…-sm.webp 640w, …-md.webp 1280w, …-lg.webp 2048w".
*/
public function srcset(): string
{
return collect(self::WIDTHS)
->map(fn (int $width, string $name): string => $this->url($name).' '.$width.'w')
->implode(', ');
}
}
+8
View File
@@ -69,6 +69,14 @@ public function blockedPeriods(): HasMany
return $this->hasMany(BlockedPeriod::class)->orderBy('starts_on');
}
/**
* @return HasMany<Amenity, $this>
*/
public function amenities(): HasMany
{
return $this->hasMany(Amenity::class)->orderBy('sort_order');
}
/**
* @return HasMany<SpecialOffer, $this>
*/
+110
View File
@@ -0,0 +1,110 @@
<?php
namespace App\Models;
use App\Enums\ReviewStatus;
use Database\Factories\ReviewFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A guest review. Reviews from the website always belong to a booking (verified stay);
* reviews taken over from portals carry their source instead.
*/
#[Fillable([
'property_id',
'booking_id',
'status',
'source',
'rating',
'rating_cleanliness',
'rating_equipment',
'rating_location',
'rating_host',
'title',
'body',
'private_feedback',
'display_name',
'publish_consent',
'stayed_on',
'response',
'responded_at',
'approved_at',
])]
class Review extends Model
{
/** @use HasFactory<ReviewFactory> */
use HasFactory;
/** Rating categories besides the overall rating, with their German labels. */
public const CATEGORIES = [
'rating_cleanliness' => 'Sauberkeit',
'rating_equipment' => 'Ausstattung',
'rating_location' => 'Lage',
'rating_host' => 'Gastgeber',
];
protected static function booted(): void
{
static::saving(function (Review $review): void {
if ($review->status === ReviewStatus::Approved && $review->approved_at === null) {
$review->approved_at = now();
}
if ($review->isDirty('response')) {
$review->responded_at = filled($review->response) ? now() : null;
}
});
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'status' => ReviewStatus::class,
'publish_consent' => 'boolean',
'stayed_on' => 'immutable_date',
'responded_at' => 'immutable_datetime',
'approved_at' => 'immutable_datetime',
];
}
/**
* @return BelongsTo<Property, $this>
*/
public function property(): BelongsTo
{
return $this->belongsTo(Property::class);
}
/**
* @return BelongsTo<Booking, $this>
*/
public function booking(): BelongsTo
{
return $this->belongsTo(Booking::class);
}
/**
* Reviews that may be shown on the website.
*
* @param Builder<Review> $query
* @return Builder<Review>
*/
#[Scope]
protected function published(Builder $query): Builder
{
return $query
->where('status', ReviewStatus::Approved)
->where('publish_consent', true)
->latest('stayed_on');
}
}
+10 -3
View File
@@ -3,6 +3,7 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Enums\UserRole;
use Database\Factories\UserFactory;
use Filament\Models\Contracts\FilamentUser;
use Filament\Panel;
@@ -12,7 +13,7 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
#[Fillable(['name', 'email', 'password'])]
#[Fillable(['name', 'email', 'role', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable implements FilamentUser
{
@@ -20,11 +21,16 @@ class User extends Authenticatable implements FilamentUser
use HasFactory, Notifiable;
/**
* Only administrators have accounts; there is no public registration.
* Accounts are created by administrators only; an account without a role has no access.
*/
public function canAccessPanel(Panel $panel): bool
{
return true;
return $this->role !== null;
}
public function hasRole(UserRole ...$roles): bool
{
return in_array($this->role, $roles, true);
}
/**
@@ -37,6 +43,7 @@ protected function casts(): array
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'role' => UserRole::class,
];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class AmenityPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Content];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class BookingPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Rentals];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class FaqPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Content];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class GuestPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Rentals];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class NoticePolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Content];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class PhotoPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Content];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class PropertyPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Rentals];
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
class ReviewPolicy extends RolePolicy
{
protected function roles(): array
{
return [UserRole::Rentals, UserRole::Content];
}
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace App\Policies;
use App\Enums\UserRole;
use App\Models\User;
/**
* Grants every ability to the roles listed in roles(). Administrators always have access.
*/
abstract class RolePolicy
{
/**
* @return list<UserRole>
*/
abstract protected function roles(): array;
public function viewAny(User $user): bool
{
return $this->allows($user);
}
public function view(User $user): bool
{
return $this->allows($user);
}
public function create(User $user): bool
{
return $this->allows($user);
}
public function update(User $user): bool
{
return $this->allows($user);
}
public function delete(User $user): bool
{
return $this->allows($user);
}
public function deleteAny(User $user): bool
{
return $this->allows($user);
}
public function reorder(User $user): bool
{
return $this->allows($user);
}
protected function allows(User $user): bool
{
return $user->hasRole(UserRole::Admin, ...$this->roles());
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Policies;
use App\Models\User;
/**
* Only administrators manage accounts; nobody can delete their own account.
*/
class UserPolicy extends RolePolicy
{
protected function roles(): array
{
return [];
}
public function delete(User $user, ?User $model = null): bool
{
return $this->allows($user) && ! $user->is($model);
}
}
@@ -28,6 +28,7 @@ public function panel(Panel $panel): Panel
->path('admin')
->login()
->brandName('FeWo Stommer · Verwaltung')
->navigationGroups(['Vermietung', 'Webseite', 'System'])
->colors([
'primary' => Color::Sky,
])
+87
View File
@@ -0,0 +1,87 @@
<?php
namespace App\Support;
use App\Models\ContentBlock;
use App\Models\Photo;
use Filament\Forms\Components\RichEditor\RichContentRenderer;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\HtmlString;
use InvalidArgumentException;
/**
* Read access to the editable website texts defined in config/content.php.
*/
class Content
{
private const CACHE_KEY = 'content-blocks';
/**
* The stored value, or the configured default when nothing was saved.
*/
public static function get(string $key): ?string
{
$definition = self::definition($key);
$stored = self::stored()[$key] ?? null;
return filled($stored) ? $stored : ($definition['default'] ?? null);
}
/**
* Rich text as sanitised HTML, ready for {{ }} output in Blade.
*/
public static function html(string $key): HtmlString
{
return new HtmlString(RichContentRenderer::make(self::get($key) ?? '')->toHtml());
}
public static function photo(string $key): ?Photo
{
$id = self::get($key);
return $id ? Photo::find((int) $id) : null;
}
/**
* @param array<string, ?string> $values
*/
public static function save(array $values): void
{
foreach ($values as $key => $value) {
self::definition($key);
ContentBlock::updateOrCreate(['key' => $key], ['value' => $value]);
}
Cache::forget(self::CACHE_KEY);
}
/**
* @return array<string, array{label: string, fields: array<string, array{label: string, type: string, default?: ?string}>}>
*/
public static function sections(): array
{
return config('content');
}
/**
* @return array{label: string, type: string, default?: ?string}
*/
private static function definition(string $key): array
{
foreach (self::sections() as $section) {
if (isset($section['fields'][$key])) {
return $section['fields'][$key];
}
}
throw new InvalidArgumentException("Unknown content key [{$key}].");
}
/**
* @return array<string, ?string>
*/
private static function stored(): array
{
return Cache::rememberForever(self::CACHE_KEY, fn (): array => ContentBlock::pluck('value', 'key')->all());
}
}
+1
View File
@@ -9,6 +9,7 @@
"php": "^8.3",
"barryvdh/laravel-dompdf": "^3.1",
"filament/filament": "^5.10",
"filament/spatie-laravel-media-library-plugin": "^5.0",
"laravel/framework": "^13.17",
"laravel/tinker": "^3.0"
},
Generated
+494 -78
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b824e8039e614f6ba029ba896794c96a",
"content-hash": "1f5e3ea95226f9ee49c3baddc64e655e",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@@ -739,6 +739,83 @@
],
"time": "2026-06-07T11:47:49+00:00"
},
{
"name": "composer/semver",
"version": "3.5.1",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "528948210cc46f967a4b98e83b19e76f2b504993"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/528948210cc46f967a4b98e83b19e76f2b504993",
"reference": "528948210cc46f967a4b98e83b19e76f2b504993",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"symfony/phpunit-bridge": "^3 || ^7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Version comparison library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.5.1"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
}
],
"time": "2026-10-05T13:12:12+00:00"
},
{
"name": "danharrin/date-format-converter",
"version": "v0.3.1",
@@ -1713,6 +1790,43 @@
},
"time": "2026-10-20T18:28:40+00:00"
},
{
"name": "filament/spatie-laravel-media-library-plugin",
"version": "v5.10.3",
"source": {
"type": "git",
"url": "https://github.com/filamentphp/spatie-laravel-media-library-plugin.git",
"reference": "062f9bfdc64cbe9ec1c65e0754a44d52514445ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/filamentphp/spatie-laravel-media-library-plugin/zipball/062f9bfdc64cbe9ec1c65e0754a44d52514445ff",
"reference": "062f9bfdc64cbe9ec1c65e0754a44d52514445ff",
"shasum": ""
},
"require": {
"filament/support": "self.version",
"php": "^8.2",
"spatie/laravel-medialibrary": "^11.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Filament\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Filament support for `spatie/laravel-medialibrary`.",
"homepage": "https://github.com/filamentphp/filament",
"support": {
"issues": "https://github.com/filamentphp/filament/issues",
"source": "https://github.com/filamentphp/filament"
},
"time": "2026-10-06T18:18:24+00:00"
},
{
"name": "filament/support",
"version": "v5.10.3",
@@ -3704,6 +3818,84 @@
],
"time": "2026-10-21T12:53:46+00:00"
},
{
"name": "maennchen/zipstream-php",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/maennchen/ZipStream-PHP.git",
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
"reference": "77bebeb4c6c340bb3c11c843b2cffd8bbfde4d5e",
"shasum": ""
},
"require": {
"ext-mbstring": "*",
"ext-zlib": "*",
"php-64bit": "^8.3"
},
"require-dev": {
"brianium/paratest": "^7.7",
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^3.86",
"guzzlehttp/guzzle": "^7.5",
"mikey179/vfsstream": "^1.6",
"php-coveralls/php-coveralls": "^2.5",
"phpunit/phpunit": "^12.0",
"vimeo/psalm": "^6.0"
},
"suggest": {
"guzzlehttp/psr7": "^2.4",
"psr/http-message": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"ZipStream\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paul Duncan",
"email": "pabs@pablotron.org"
},
{
"name": "Jonatan Männchen",
"email": "jonatan@maennchen.ch"
},
{
"name": "Jesse Donat",
"email": "donatj@gmail.com"
},
{
"name": "András Kolesár",
"email": "kolesar@kolesar.hu"
}
],
"description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.",
"keywords": [
"stream",
"zip"
],
"support": {
"issues": "https://github.com/maennchen/ZipStream-PHP/issues",
"source": "https://github.com/maennchen/ZipStream-PHP/tree/3.2.2"
},
"funding": [
{
"url": "https://github.com/maennchen",
"type": "github"
}
],
"time": "2026-04-11T18:38:28+00:00"
},
{
"name": "masterminds/html5",
"version": "2.11.0",
@@ -5603,6 +5795,136 @@
],
"time": "2022-12-17T21:53:22+00:00"
},
{
"name": "spatie/image",
"version": "3.9.9",
"source": {
"type": "git",
"url": "https://github.com/spatie/image.git",
"reference": "929c00fdab6c0c929e69524fffd1a658167cbcc2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image/zipball/929c00fdab6c0c929e69524fffd1a658167cbcc2",
"reference": "929c00fdab6c0c929e69524fffd1a658167cbcc2",
"shasum": ""
},
"require": {
"ext-exif": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": "^8.4",
"spatie/image-optimizer": "^1.7.5",
"spatie/temporary-directory": "^2.2",
"symfony/process": "^6.4|^7.0|^8.0"
},
"require-dev": {
"ext-ffi": "*",
"ext-gd": "*",
"ext-imagick": "*",
"jcupitt/vips": "^2.4",
"laravel/sail": "^1.34",
"pestphp/pest": "^5.0",
"phpstan/phpstan": "^1.10.50",
"spatie/pest-plugin-snapshots": "^2.4",
"spatie/pixelmatch-php": "^1.0",
"spatie/ray": "^1.40.1",
"symfony/var-dumper": "^6.4|^7.0|^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\Image\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Manipulate images with an expressive API",
"homepage": "https://github.com/spatie/image",
"keywords": [
"image",
"spatie"
],
"support": {
"source": "https://github.com/spatie/image/tree/3.9.9"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-10-20T06:00:43+00:00"
},
{
"name": "spatie/image-optimizer",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/image-optimizer.git",
"reference": "333c03952289dc2df0a91874636a0dffeb5b6aec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/image-optimizer/zipball/333c03952289dc2df0a91874636a0dffeb5b6aec",
"reference": "333c03952289dc2df0a91874636a0dffeb5b6aec",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"php": "^7.4|^8.0",
"psr/log": "^1.0 | ^2.0 | ^3.0",
"symfony/process": "^4.2|^5.0|^6.0|^7.0|^8.0"
},
"require-dev": {
"pestphp/pest": "^1.21|^2.0|^3.0|^4.0",
"phpunit/phpunit": "^8.5.21|^9.4.4|^10.0|^11.0|^12.0",
"symfony/var-dumper": "^4.2|^5.0|^6.0|^7.0|^8.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\ImageOptimizer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily optimize images using PHP",
"homepage": "https://github.com/spatie/image-optimizer",
"keywords": [
"image-optimizer",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/image-optimizer/issues",
"source": "https://github.com/spatie/image-optimizer/tree/1.10.0"
},
"time": "2026-06-29T08:28:30+00:00"
},
{
"name": "spatie/invade",
"version": "2.2.0",
@@ -5670,6 +5992,116 @@
],
"time": "2026-10-19T16:16:47+00:00"
},
{
"name": "spatie/laravel-medialibrary",
"version": "11.23.10",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-medialibrary.git",
"reference": "e32803a1295c001ad53a1e9c8468f5a39b4df37f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/e32803a1295c001ad53a1e9c8468f5a39b4df37f",
"reference": "e32803a1295c001ad53a1e9c8468f5a39b4df37f",
"shasum": ""
},
"require": {
"composer/semver": "^3.4",
"ext-exif": "*",
"ext-fileinfo": "*",
"ext-json": "*",
"illuminate/bus": "^12.0|^13.0",
"illuminate/conditionable": "^12.0|^13.0",
"illuminate/console": "^12.0|^13.0",
"illuminate/database": "^12.0|^13.0",
"illuminate/pipeline": "^12.0|^13.0",
"illuminate/support": "^12.0|^13.0",
"maennchen/zipstream-php": "^3.1",
"php": "^8.2",
"spatie/image": "^3.3.2",
"spatie/laravel-package-tools": "^1.16.1",
"spatie/temporary-directory": "^2.2",
"symfony/console": "^6.4.1|^7.0|^8.0"
},
"conflict": {
"php-ffmpeg/php-ffmpeg": "<0.6.1"
},
"require-dev": {
"aws/aws-sdk-php": "^3.293.10",
"ext-imagick": "*",
"ext-pdo_sqlite": "*",
"ext-zip": "*",
"guzzlehttp/guzzle": "^7.8.1",
"larastan/larastan": "^3.13",
"league/flysystem-aws-s3-v3": "^3.22",
"mockery/mockery": "^1.6.7",
"orchestra/testbench": "^10.12|^11.3",
"pestphp/pest": "^3.8.7|^4.7.8|^5.3.3",
"phpstan/extension-installer": "^1.3.1",
"spatie/laravel-ray": "^1.33",
"spatie/pdf-to-image": "^2.2|^3.0",
"spatie/pest-expectations": "^1.13",
"spatie/pest-plugin-snapshots": "^2.3.1"
},
"suggest": {
"league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage",
"php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails",
"spatie/pdf-to-image": "Required for generating thumbnails of PDFs and SVGs"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Spatie\\MediaLibrary\\MediaLibraryServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Spatie\\MediaLibrary\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Associate files with Eloquent models",
"homepage": "https://github.com/spatie/laravel-medialibrary",
"keywords": [
"cms",
"conversion",
"downloads",
"images",
"laravel",
"laravel-medialibrary",
"media",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-medialibrary/issues",
"source": "https://github.com/spatie/laravel-medialibrary/tree/11.23.10"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-10-19T12:45:53+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.93.3",
@@ -5796,6 +6228,67 @@
],
"time": "2026-04-27T14:27:52+00:00"
},
{
"name": "spatie/temporary-directory",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/temporary-directory.git",
"reference": "32cbb9645b28839cf4f476708e99a2c70e6802c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/temporary-directory/zipball/32cbb9645b28839cf4f476708e99a2c70e6802c9",
"reference": "32cbb9645b28839cf4f476708e99a2c70e6802c9",
"shasum": ""
},
"require": {
"php": "^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\TemporaryDirectory\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Alex Vanderbist",
"email": "alex@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"description": "Easily create, use and destroy temporary directories",
"homepage": "https://github.com/spatie/temporary-directory",
"keywords": [
"php",
"spatie",
"temporary-directory"
],
"support": {
"issues": "https://github.com/spatie/temporary-directory/issues",
"source": "https://github.com/spatie/temporary-directory/tree/2.4.0"
},
"funding": [
{
"url": "https://spatie.be/open-source/support-us",
"type": "custom"
},
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2026-06-22T07:55:44+00:00"
},
{
"name": "symfony/clock",
"version": "v8.1.9",
@@ -8795,83 +9288,6 @@
}
],
"packages-dev": [
{
"name": "composer/semver",
"version": "3.5.1",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "528948210cc46f967a4b98e83b19e76f2b504993"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/528948210cc46f967a4b98e83b19e76f2b504993",
"reference": "528948210cc46f967a4b98e83b19e76f2b504993",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpstan/phpstan": "^1.11",
"symfony/phpunit-bridge": "^3 || ^7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Version comparison library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"support": {
"irc": "ircs://irc.libera.chat:6697/composer",
"issues": "https://github.com/composer/semver/issues",
"source": "https://github.com/composer/semver/tree/3.5.1"
},
"funding": [
{
"url": "https://packagist.com",
"type": "custom"
},
{
"url": "https://github.com/composer",
"type": "github"
}
],
"time": "2026-10-05T13:12:12+00:00"
},
{
"name": "fakerphp/faker",
"version": "v1.24.1",
+81
View File
@@ -0,0 +1,81 @@
<?php
/*
|--------------------------------------------------------------------------
| Editable website texts
|--------------------------------------------------------------------------
|
| Every field becomes an input on the admin page "Webseiten-Texte", grouped
| by section. Types: text, textarea, richtext (sanitised HTML), photo (id of
| a Photo). The default is shown until a value has been saved.
|
*/
return [
'home' => [
'label' => 'Startseite',
'fields' => [
'home.hero.eyebrow' => ['label' => 'Kleine Überschrift', 'type' => 'text', 'default' => 'Ostseebad Kühlungsborn'],
'home.hero.title' => ['label' => 'Hauptüberschrift', 'type' => 'text', 'default' => 'Ihr Zuhause zwischen Garten und Meer'],
'home.hero.text' => ['label' => 'Einleitungstext', 'type' => 'textarea', 'default' => '53 m² im Erdgeschoss, eigene Terrasse mit Blick auf Teich und Garten – ruhig gelegen in der Strandstraße.'],
'home.hero.photo' => ['label' => 'Titelbild', 'type' => 'photo'],
'home.intro.title' => ['label' => 'Abschnitt „Die Wohnung“: Überschrift', 'type' => 'text', 'default' => 'Ankommen, Tür auf, Terrasse – und durchatmen.'],
'home.intro.text' => ['label' => 'Abschnitt „Die Wohnung“: Text', 'type' => 'richtext', 'default' => '<p>Helles Wohnzimmer mit Ledersofa und Schrankbett, ein ruhiges Schlafzimmer mit Verdunkelung, eine voll ausgestattete Küche mit Geschirrspüler und ein Bad mit bodennaher Dusche.</p>'],
'home.location.title' => ['label' => 'Abschnitt „Lage“: Überschrift', 'type' => 'text', 'default' => 'Kühlungsborn – Strand, Hafen und Bäderarchitektur.'],
'home.location.text' => ['label' => 'Abschnitt „Lage“: Text', 'type' => 'richtext', 'default' => '<p>Zu Fuß an die Ostsee, zum Bootshafen in Kühlungsborn Ost oder mit der Dampflok „Molli“ nach Bad Doberan.</p>'],
],
],
'apartment' => [
'label' => 'Die Wohnung',
'fields' => [
'apartment.title' => ['label' => 'Überschrift', 'type' => 'text', 'default' => 'Die Wohnung'],
'apartment.text' => ['label' => 'Beschreibung', 'type' => 'richtext', 'default' => '<p>Unsere 53 m² große Ferienwohnung liegt im Erdgeschoss und bietet Platz für ein bis drei Personen. Wohnzimmer, Schlafzimmer, Küche mit Essbereich, Diele, Bad und eine eigene Terrasse mit Blick auf Teich und Garten.</p>'],
'apartment.floorplan' => ['label' => 'Grundriss', 'type' => 'photo'],
],
],
'area' => [
'label' => 'Kühlungsborn',
'fields' => [
'area.title' => ['label' => 'Überschrift', 'type' => 'text', 'default' => 'Kühlungsborn & Umgebung'],
'area.text' => ['label' => 'Text', 'type' => 'richtext', 'default' => '<p>Kühlungsborn ist eines der schönsten Ostseebäder – mit breitem Sandstrand, Strandpromenade, Bootshafen und prachtvoller Bäderarchitektur.</p>'],
],
],
'host' => [
'label' => 'Gastgeber',
'fields' => [
'host.quote' => ['label' => 'Zitat', 'type' => 'textarea', 'default' => 'Wir vermieten unsere Wohnung seit über 20 Jahren – und freuen uns jedes Mal, wenn Gäste wiederkommen.'],
'host.text' => ['label' => 'Text', 'type' => 'richtext', 'default' => '<p>Sie erreichen uns persönlich per Telefon oder E-Mail.</p>'],
'host.photo' => ['label' => 'Foto der Gastgeberin', 'type' => 'photo'],
],
],
'stay' => [
'label' => 'Aufenthalt',
'fields' => [
'stay.house_rules' => ['label' => 'Hausregeln', 'type' => 'richtext', 'default' => null],
'stay.arrival_info' => ['label' => 'Anreiseinformationen (für Gäste-E-Mail vor Anreise)', 'type' => 'richtext', 'default' => null],
'stay.cancellation' => ['label' => 'Stornobedingungen', 'type' => 'richtext', 'default' => null],
],
],
'legal' => [
'label' => 'Rechtliches',
'fields' => [
'legal.imprint' => ['label' => 'Impressum', 'type' => 'richtext', 'default' => null],
'legal.privacy' => ['label' => 'Datenschutzerklärung', 'type' => 'richtext', 'default' => null],
],
],
'seo' => [
'label' => 'Suchmaschinen',
'fields' => [
'seo.home.title' => ['label' => 'Seitentitel (Google)', 'type' => 'text', 'default' => 'Ferienwohnung Stommer in Kühlungsborn – Terrasse, Garten, Ostsee'],
'seo.home.description' => ['label' => 'Beschreibung (Google)', 'type' => 'textarea', 'default' => 'Gemütliche 53 m² Ferienwohnung im Erdgeschoss mit eigener Terrasse in Kühlungsborn. Freie Termine und Preise online prüfen und unverbindlich anfragen.'],
],
],
];
+12
View File
@@ -34,4 +34,16 @@
*/
'deposit_due_days' => (int) env('FEWO_DEPOSIT_DUE_DAYS', 7),
/*
| Days after departure when guests are asked for a review.
*/
'review_request_after_days' => (int) env('FEWO_REVIEW_REQUEST_AFTER_DAYS', 2),
/*
| Years after the last stay after which guest data is anonymised automatically.
| Default 10 years because booking records are accounting documents (§ 147 AO);
| please confirm with your tax advisor.
*/
'guest_retention_years' => (int) env('FEWO_GUEST_RETENTION_YEARS', 10),
];
+363
View File
@@ -0,0 +1,363 @@
<?php
use Spatie\ImageOptimizer\Optimizers\Avifenc;
use Spatie\ImageOptimizer\Optimizers\Cwebp;
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
use Spatie\ImageOptimizer\Optimizers\Optipng;
use Spatie\ImageOptimizer\Optimizers\Pngquant;
use Spatie\ImageOptimizer\Optimizers\Svgo;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Avif;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Image;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Svg;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Video;
use Spatie\MediaLibrary\Conversions\ImageGenerators\Webp;
use Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob;
use Spatie\MediaLibrary\Downloaders\DefaultDownloader;
use Spatie\MediaLibrary\MediaCollections\FileAdder;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\MediaCollections\Models\Observers\MediaObserver;
use Spatie\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob;
use Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred;
use Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator;
use Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer;
use Spatie\MediaLibrary\Support\FileRemover\DefaultFileRemover;
use Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator;
use Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator;
use Spatie\MediaLibraryPro\Models\TemporaryUpload;
return [
/*
* The disk on which to store added files and derived images by default. Choose
* one or more of the disks you've configured in config/filesystems.php.
*/
'disk_name' => env('MEDIA_DISK', 'public'),
/*
* The disk on which to store conversions (thumbnails, etc.) and responsive images
* when no disk is specified explicitly on the media collection or via
* `storingConversionsOnDisk()`. When left null, conversions are stored on the
* same disk as the original media — preserving previous behavior.
*
* This is useful when the originals live on a remote disk (e.g. S3) but the
* generated derivatives should stay local for faster access and lower egress.
*/
'conversions_disk_name' => env('MEDIA_CONVERSIONS_DISK', null),
/*
* The maximum file size of an item in bytes.
* Adding a larger file will result in an exception.
*/
'max_file_size' => 1024 * 1024 * 10, // 10MB
/*
* Uploads whose file name contains any of these extensions will be rejected.
* The check looks at every extension in the file name, so a file named
* `malicious.php.jpg` is blocked as well. Matching is case-insensitive
* and a leading dot is optional.
*
* The default list lives on the `FileAdder` class so the shipped config
* and the in-code fallback (used when the config is cached without the
* key) cannot drift. Override here to extend or shrink it.
*/
'disallowed_extensions' => FileAdder::$defaultDisallowedExtensions,
/*
* When this is set to an array of extensions, only uploads whose final
* extension is in the list will be accepted. Matching is case-insensitive
* and a leading dot is optional. The `disallowed_extensions` list above
* is still enforced, so an interior dangerous segment (such as the `php`
* in `shell.php.jpg`) is rejected even if the final extension is allowed.
* Leave `null` to disable allowlisting.
*/
'allowed_extensions' => null,
/*
* This queue connection will be used to generate derived and responsive images.
* Leave empty to use the default queue connection.
*/
'queue_connection_name' => env('QUEUE_CONNECTION', 'sync'),
/*
* This queue will be used to generate derived and responsive images.
* Leave empty to use the default queue.
*/
'queue_name' => env('MEDIA_QUEUE', ''),
/*
* By default all conversions will be performed on a queue.
*/
'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', false),
/*
* Should database transactions be run after database commits?
*/
'queue_conversions_after_database_commit' => env('QUEUE_CONVERSIONS_AFTER_DB_COMMIT', true),
/*
* The fully qualified class name of the media model.
*/
'media_model' => Media::class,
/*
* The fully qualified class name of the media observer.
*/
'media_observer' => MediaObserver::class,
/*
* When enabled, media collections will be serialised using the default
* laravel model serialization behaviour.
*
* Keep this option disabled if using Media Library Pro components (https://medialibrary.pro)
*/
'use_default_collection_serialization' => false,
/*
* The fully qualified class name of the model used for temporary uploads.
*
* This model is only used in Media Library Pro (https://medialibrary.pro)
*/
'temporary_upload_model' => TemporaryUpload::class,
/*
* When enabled, Media Library Pro will only process temporary uploads that were uploaded
* in the same session. You can opt to disable this for stateless usage of
* the pro components.
*/
'enable_temporary_uploads_session_affinity' => true,
/*
* When enabled, Media Library pro will generate thumbnails for uploaded file.
*/
'generate_thumbnails_for_temporary_uploads' => true,
/*
* This is the class that is responsible for naming generated files.
*/
'file_namer' => DefaultFileNamer::class,
/*
* The class that contains the strategy for determining a media file's path.
*/
'path_generator' => DefaultPathGenerator::class,
/*
* The class that contains the strategy for determining how to remove files.
*/
'file_remover_class' => DefaultFileRemover::class,
/*
* Here you can specify which path generator should be used for the given class.
*/
'custom_path_generators' => [
// Model::class => PathGenerator::class
// or
// 'model_morph_alias' => PathGenerator::class
],
/*
* When urls to files get generated, this class will be called. Use the default
* if your files are stored locally above the site root or on s3.
*/
'url_generator' => DefaultUrlGenerator::class,
/*
* Moves media on updating to keep path consistent. Enable it only with a custom
* PathGenerator that uses, for example, the media UUID.
*/
'moves_media_on_update' => false,
/*
* Whether to activate versioning when urls to files get generated.
* When activated, this attaches a ?v=xx query string to the URL.
*/
'version_urls' => false,
/*
* The media library will try to optimize all converted images by removing
* metadata and applying a little bit of compression. These are
* the optimizers that will be used by default.
*/
'image_optimizers' => [
Jpegoptim::class => [
'-m85', // set maximum quality to 85%
'--force', // ensure that progressive generation is always done also if a little bigger
'--strip-all', // this strips out all text information such as comments and EXIF data
'--all-progressive', // this will make sure the resulting image is a progressive one
],
Pngquant::class => [
'--force', // required parameter for this package
],
Optipng::class => [
'-i0', // this will result in a non-interlaced, progressive scanned image
'-o2', // this set the optimization level to two (multiple IDAT compression trials)
'-quiet', // required parameter for this package
],
Svgo::class => [
'--disable=cleanupIDs', // disabling because it is known to cause troubles
],
Gifsicle::class => [
'-b', // required parameter for this package
'-O3', // this produces the slowest but best results
],
Cwebp::class => [
'-m 6', // for the slowest compression method in order to get the best compression.
'-pass 10', // for maximizing the amount of analysis pass.
'-mt', // multithreading for some speed improvements.
'-q 90', // quality factor that brings the least noticeable changes.
],
Avifenc::class => [
'-a cq-level=23', // constant quality level, lower values mean better quality and greater file size (0-63).
'-j all', // number of jobs (worker threads, "all" uses all available cores).
'--min 0', // min quantizer for color (0-63).
'--max 63', // max quantizer for color (0-63).
'--minalpha 0', // min quantizer for alpha (0-63).
'--maxalpha 63', // max quantizer for alpha (0-63).
'-a end-usage=q', // rate control mode set to Constant Quality mode.
'-a tune=ssim', // SSIM as tune the encoder for distortion metric.
],
],
/*
* These generators will be used to create an image of media files.
*/
'image_generators' => [
Image::class,
Webp::class,
Avif::class,
Pdf::class,
Svg::class,
Video::class,
],
/*
* The path where to store temporary files while performing image conversions.
* If set to null, storage_path('media-library/temp') will be used.
*/
'temporary_directory_path' => null,
/*
* The engine that should perform the image conversions.
* Should be either `gd`, `imagick` or `vips`.
*/
'image_driver' => env('IMAGE_DRIVER', 'gd'),
/*
* FFMPEG & FFProbe binaries paths, only used if you try to generate video
* thumbnails and have installed the php-ffmpeg/php-ffmpeg composer
* dependency.
*/
'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'),
'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'),
/*
* The timeout (in seconds) that will be used when generating video
* thumbnails via FFMPEG.
*/
'ffmpeg_timeout' => env('FFMPEG_TIMEOUT', 900),
/*
* The number of threads that FFMPEG should use. 0 means that FFMPEG
* may decide itself.
*/
'ffmpeg_threads' => env('FFMPEG_THREADS', 0),
/*
* Here you can override the class names of the jobs used by this package. Make sure
* your custom jobs extend the ones provided by the package.
*/
'jobs' => [
'perform_conversions' => PerformConversionsJob::class,
'generate_responsive_images' => GenerateResponsiveImagesJob::class,
],
/*
* When using the addMediaFromUrl method you may want to replace the default downloader.
* This is particularly useful when the url of the image is behind a firewall and
* need to add additional flags, possibly using curl.
*/
'media_downloader' => DefaultDownloader::class,
/*
* When using the addMediaFromUrl method the SSL is verified by default.
* This is option disables SSL verification when downloading remote media.
* Please note that this is a security risk and should only be false in a local environment.
*/
'media_downloader_ssl' => env('MEDIA_DOWNLOADER_SSL', true),
/*
* The default lifetime in minutes for temporary urls.
* This is used when you call the `getLastTemporaryUrl` or `getLastTemporaryUrl` method on a media item.
*/
'temporary_url_default_lifetime' => env('MEDIA_TEMPORARY_URL_DEFAULT_LIFETIME', 5),
'remote' => [
/*
* Any extra headers that should be included when uploading media to
* a remote disk. Even though supported headers may vary between
* different drivers, a sensible default has been provided.
*
* Supported by S3: CacheControl, Expires, StorageClass,
* ServerSideEncryption, Metadata, ACL, ContentEncoding
*/
'extra_headers' => [
'CacheControl' => 'max-age=604800',
],
],
'responsive_images' => [
/*
* This class is responsible for calculating the target widths of the responsive
* images. By default we optimize for filesize and create variations that each are 30%
* smaller than the previous one. More info in the documentation.
*
* https://docs.spatie.be/laravel-medialibrary/v9/advanced-usage/generating-responsive-images
*/
'width_calculator' => FileSizeOptimizedWidthCalculator::class,
/*
* By default rendering media to a responsive image will add some javascript and a tiny placeholder.
* This ensures that the browser can already determine the correct layout.
* When disabled, no tiny placeholder is generated.
*/
'use_tiny_placeholders' => true,
/*
* This class will generate the tiny placeholder used for progressive image loading. By default
* the media library will use a tiny blurred jpg image.
*/
'tiny_placeholder_generator' => Blurred::class,
],
/*
* When enabling this option, a route will be registered that will enable
* the Media Library Pro Vue and React components to move uploaded files
* in a S3 bucket to their right place.
*/
'enable_vapor_uploads' => env('ENABLE_MEDIA_LIBRARY_VAPOR_UPLOADS', false),
/*
* When converting Media instances to response the media library will add
* a `loading` attribute to the `img` tag. Here you can set the default
* value of that attribute.
*
* Possible values: 'lazy', 'eager', 'auto' or null if you don't want to set any loading instruction.
*
* More info: https://css-tricks.com/native-lazy-loading/
*/
'default_loading_attribute_value' => null,
/*
* You can specify a prefix for that is used for storing all media.
* If you set this to `/my-subdir`, all your media will be stored in a `/my-subdir` directory.
*/
'prefix' => env('MEDIA_PREFIX', ''),
/*
* When forcing lazy loading, media will be loaded even if you don't eager load media and you have
* disabled lazy loading globally in the service provider.
*/
'force_lazy_loading' => env('FORCE_MEDIA_LIBRARY_LAZY_LOADING', true),
];
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace Database\Factories;
use App\Enums\AmenityArea;
use App\Models\Amenity;
use App\Models\Property;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Amenity>
*/
class AmenityFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'property_id' => Property::factory(),
'area' => AmenityArea::General,
'name' => fake()->words(2, true),
'is_highlight' => false,
'sort_order' => 0,
];
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Database\Factories;
use App\Models\Faq;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Faq>
*/
class FaqFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'question' => fake()->sentence().'?',
'answer' => '<p>'.fake()->paragraph().'</p>',
'is_published' => true,
'sort_order' => 0,
];
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace Database\Factories;
use App\Enums\NoticeTone;
use App\Models\Notice;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Notice>
*/
class NoticeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'text' => fake()->sentence(),
'tone' => NoticeTone::Info,
'is_active' => true,
];
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Enums\PhotoCategory;
use App\Models\Photo;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Photo>
*/
class PhotoFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'category' => PhotoCategory::Apartment,
'alt_text' => fake()->sentence(3),
'is_published' => true,
'sort_order' => 0,
];
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace Database\Factories;
use App\Enums\ReviewStatus;
use App\Models\Property;
use App\Models\Review;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Review>
*/
class ReviewFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'property_id' => Property::factory(),
'status' => ReviewStatus::Pending,
'source' => 'website',
'rating' => 5,
'body' => fake()->paragraph(),
'display_name' => fake()->firstName().' '.fake()->randomLetter().'.',
'publish_consent' => true,
'stayed_on' => fake()->dateTimeBetween('-1 year')->format('Y-m-d'),
];
}
}
+7
View File
@@ -2,6 +2,7 @@
namespace Database\Factories;
use App\Enums\UserRole;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
@@ -30,9 +31,15 @@ public function definition(): array
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'role' => UserRole::Admin,
];
}
public function role(?UserRole $role): static
{
return $this->state(fn (): array => ['role' => $role]);
}
/**
* Indicate that the model's email address should be unverified.
*/
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('media', function (Blueprint $table) {
$table->id();
$table->morphs('model');
$table->uuid()->nullable()->unique();
$table->string('collection_name');
$table->string('name');
$table->string('file_name');
$table->string('mime_type')->nullable();
$table->string('disk');
$table->string('conversions_disk')->nullable();
$table->unsignedBigInteger('size');
$table->json('manipulations');
$table->json('custom_properties');
$table->json('generated_conversions');
$table->json('responsive_images');
$table->unsignedInteger('order_column')->nullable()->index();
$table->nullableTimestamps();
});
}
};
@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->string('role')->nullable()->after('email');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('role');
});
}
};
@@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('photos', function (Blueprint $table) {
$table->id();
$table->foreignId('property_id')->nullable()->constrained()->nullOnDelete();
$table->string('category');
$table->string('alt_text');
$table->string('caption')->nullable();
$table->boolean('is_published')->default(true);
$table->unsignedSmallInteger('sort_order')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('photos');
}
};
@@ -0,0 +1,29 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('content_blocks', function (Blueprint $table) {
$table->id();
$table->string('key')->unique();
$table->longText('value')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('content_blocks');
}
};
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('faqs', function (Blueprint $table) {
$table->id();
$table->string('question');
$table->text('answer');
$table->boolean('is_published')->default(true);
$table->unsignedSmallInteger('sort_order')->default(0);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('faqs');
}
};
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff. Show more