Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d42c42059c | ||
|
|
f5f18cd984 | ||
|
|
1c757f7429 | ||
|
|
70a39315e2 | ||
|
|
b9225f5fb8 | ||
|
|
876a0a20f3 | ||
|
|
4e6ad792eb | ||
|
|
d2b1a853dc | ||
|
|
791786ed3e | ||
|
|
d02f3e05c7 | ||
|
|
8bcda9a4bc | ||
|
|
e74033a958 | ||
|
|
add2367869 | ||
|
|
8b36e07dc4 |
No files matched your search
@@ -17,7 +17,7 @@ # Ferienwohnung Stommer
|
||||
- Website = theme system (`docs/THEMES.md`): themes live in `resources/themes/<key>` (theme.json, theme.css, theme.js, views); views resolve via the `theme::` namespace (theme → parent → base `ostsee-licht`). Pages are lists of sections (`app/Themes/Sections`, catalogue in `config/themes.php`); seasonal `Appearance`s override tokens/texts/hero photo/photos per section (stable `data.id` per placed section) and sections can be limited to appearances. Theme views use only token colour classes (`bg-accent`, `text-muted`, …). New designs are **additional** themes: `php artisan themes:make <key>`, `themes:check`, `themes:preview` – never edit `ostsee-licht` for a new design; authoring rules in `docs/THEME-ERSTELLUNG.md`. Resolve `Theme` lazily (`app(Theme::class)`), never in constructors – middleware `ResolveTheme` replaces it per request.
|
||||
- Operations (environments, Strato access, server .env, admin accounts, 2FA, known pitfalls): `docs/BETRIEB.md` – read it before touching a server. Admin accounts: `php artisan users:create`; 2FA (Filament app authentication) is mandatory for every account. Admin modes (`App\Enums\AdminMode`: simple/expert per user, user menu switch) only shape the menu via the `FollowsAdminMode` trait on every resource/page (simple menu = `AdminMode::SIMPLE_NAVIGATION`); permissions stay with roles/policies. New admin resources must use `FollowsAdminMode`.
|
||||
- Deployment: `scripts/deploy.sh <env> setup|deploy [ref]|rollback|releases|artisan` (atomic releases on Strato, docs/DEPLOYMENT.md; the server keeps only the active release because of Strato's file quota – history = Git tags `deploy/<env>/<timestamp>`); CI `.gitea/workflows/deploy.yml`. Production has no dev packages (no factories/Faker) – production seeding via `ProductionSeeder`.
|
||||
- Strato specifics: `public/index.php` strips the internal `/releases/<v>/public` prefix from `REQUEST_URI` (signed URLs); `URL::forceRootUrl(APP_URL)` outside local/testing; mail routing: `App\Support\Settings` (admin page System › Betrieb, stored on the tenant) – test mode (default) sends every mail to the test recipient only, live delivers normally; `FEWO_MAIL_REDIRECT_TO` is a hard override. Landlord data, bank, addresses and periods are columns of `tenants`: `App\Tenancy\TenantConfig` lays them over `config('fewo.*')` and `mail.from` whenever the tenant context changes, so views and mails keep reading the config keys. Send notifications to `Settings::notificationRecipients()` (never `config('fewo.notification_email')` directly). Retention periods and bot-protection counters can only be tightened against the `.env` baseline. The booking form is protected against bots (`config('fewo.spam')`: honeypot, time trap, rate limits, max open holds per e-mail) – tests that submit it instantly set `fewo.spam.min_seconds` to 0.
|
||||
- Strato specifics: `public/index.php` strips the internal `/releases/<v>/public` prefix from `REQUEST_URI` (signed URLs); `URL::forceRootUrl(APP_URL)` outside local/testing; mail routing: `App\Support\Settings` (admin page System › Betrieb, stored on the tenant) – test mode (default) sends every mail to the test recipient only, live delivers normally; `FEWO_MAIL_REDIRECT_TO` is a hard override. Landlord data, bank, addresses and periods are columns of `tenants`: `App\Tenancy\TenantConfig` lays them over `config('fewo.*')` and `mail.from` whenever the tenant context changes, so views and mails keep reading the config keys. Send notifications to `Settings::notificationRecipients()` (never `config('fewo.notification_email')` directly). Findings detected repeatedly (e.g. by the 5-minute sync) go through `AppSupportInbox` (admin Postfach, fingerprint per tenant, repeated only per the tenant's `reminder_interval_days`), never straight to mail; daily/weekly summaries: `SendDigests` + `DigestReport` (sections `DigestSection`). Retention periods and bot-protection counters can only be tightened against the `.env` baseline. The booking form is protected against bots (`config('fewo.spam')`: honeypot, time trap, rate limits, max open holds per e-mail) – tests that submit it instantly set `fewo.spam.min_seconds` to 0.
|
||||
- Vite fonts plugin is removed on purpose (corporate proxy breaks remote font downloads, and fonts must be self-hosted for GDPR).
|
||||
- PHP/Composer on this machine: winget package dir `%LOCALAPPDATA%\Microsoft\WinGet\Packages\PHP.PHP.8.4_*` (Composer as `composer\composer.phar` there).
|
||||
- Git remote: Gitea `https://gitea.stommer.de/Lars/fewo-stommer.git`, branch `main`.
|
||||
|
||||
@@ -68,6 +68,7 @@ public function handle(Channel $channel): array
|
||||
$this->store($block, [...$attributes, 'ical_properties' => $properties, 'ical_raw' => $event['raw'] ?? $block->ical_raw]);
|
||||
$counts['classified']++;
|
||||
}
|
||||
app(ReconcileChannelRepresentations::class)->handle($channel->property);
|
||||
|
||||
return $counts;
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@@ -30,6 +31,7 @@ public function handle(BlockedPeriod $occupation, OccupationKind $kind, ?int $or
|
||||
throw ValidationException::withMessages(['origin_channel_id' => 'Privat und ein externer Buchungskanal können nicht gleichzeitig gewählt werden.']);
|
||||
}
|
||||
DB::transaction(function () use ($occupation, $kind, $originId, $details): void {
|
||||
Property::query()->whereKey($occupation->property_id)->lockForUpdate()->firstOrFail();
|
||||
$record = BlockedPeriod::query()->whereKey($occupation->id)->lockForUpdate()->firstOrFail();
|
||||
if (! in_array($record->source, ['channel', 'email'], true) || $record->is_representation) {
|
||||
throw ValidationException::withMessages(['occupation_kind' => 'Nur eigenständige Portalereignisse können hier eingeordnet werden.']);
|
||||
@@ -44,6 +46,7 @@ public function handle(BlockedPeriod $occupation, OccupationKind $kind, ?int $or
|
||||
'block_purpose' => $kind === OccupationKind::Block ? (array_key_exists('block_purpose', $details) ? $details['block_purpose'] : $record->block_purpose) : null,
|
||||
'block_note' => $kind === OccupationKind::Block ? (array_key_exists('block_note', $details) ? $details['block_note'] : $record->block_note) : null,
|
||||
])->save();
|
||||
app(ReconcileChannelRepresentations::class)->handle($record->property);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,13 @@
|
||||
use App\Enums\PortalEmailStatus;
|
||||
use App\Enums\PortalEmailType;
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Mail\ChannelConflict;
|
||||
use App\Mail\PortalMailNotification;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Channel;
|
||||
use App\Models\PortalEmail;
|
||||
use App\Support\Settings;
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
@@ -80,7 +80,7 @@ public function handle(PortalMail $mail): ?PortalEmail
|
||||
}
|
||||
|
||||
if ($conflicts !== []) {
|
||||
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new ChannelConflict($channel, $conflicts)));
|
||||
app(ReportChannelConflicts::class)->handle($channel, $conflicts);
|
||||
}
|
||||
|
||||
return $record;
|
||||
@@ -126,7 +126,7 @@ public function senders(Channel $channel): array
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $conflicts
|
||||
* @param array<string, CarbonInterface> $conflicts description => first night
|
||||
* @return array{PortalEmailStatus, ?BlockedPeriod, ?string}
|
||||
*/
|
||||
private function block(Channel $channel, ParsedPortalMail $parsed, array &$conflicts): array
|
||||
@@ -158,7 +158,7 @@ private function block(Channel $channel, ParsedPortalMail $parsed, array &$confl
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => 'Überlappende Portalrepräsentationen ohne gemeinsame Kennung persönlich prüfen.'])->saveQuietly();
|
||||
}
|
||||
|
||||
$conflicts = $this->conflictDetector->conflictsFor($block);
|
||||
$conflicts = array_fill_keys($this->conflictDetector->conflictsFor($block), $block->starts_on);
|
||||
|
||||
return [PortalEmailStatus::Blocked, $block, null];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Property;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ReconcileChannelRepresentations
|
||||
{
|
||||
public const OVERLAP_NOTE = 'Mehrere Belegungsrepräsentationen oder Überschneidungen prüfen; keine automatische Zusammenführung anhand von Terminen.';
|
||||
|
||||
private const LINK_NOTE = 'Automatisch als Kalenderspiegelung einer eindeutig passenden führenden Portalreservierung zugeordnet.';
|
||||
|
||||
private const RECHECK_NOTE = 'Automatische Kalenderspiegelung nicht mehr eindeutig. Quellen, Termine und mögliche Stornierung prüfen; der weiterhin gemeldete Zeitraum bleibt belegt.';
|
||||
|
||||
/** @return array{linked: int, unlinked: int} */
|
||||
public function handle(Property $property): array
|
||||
{
|
||||
return DB::transaction(function () use ($property): array {
|
||||
$property = Property::query()->whereKey($property->id)->lockForUpdate()->firstOrFail();
|
||||
$blocks = $property->blockedPeriods()->with('channel')->withCount('channelRepresentations')->orderBy('id')->lockForUpdate()->get()->keyBy('id');
|
||||
$independent = $blocks->filter(fn (BlockedPeriod $block): bool => ! $block->is_representation || $block->representation_automatic);
|
||||
$mirrors = $independent->filter(fn (BlockedPeriod $block): bool => $this->isMirror($block));
|
||||
$leaders = $independent->filter(fn (BlockedPeriod $block): bool => $this->isLeader($block));
|
||||
$bookings = $property->bookings()->occupying()->get(['id', 'arrival', 'departure']);
|
||||
$targets = [];
|
||||
foreach ($mirrors as $mirror) {
|
||||
$matches = $leaders->filter(fn (BlockedPeriod $leader): bool => $leader->channel_id !== $mirror->channel_id && $this->sameDates($leader, $mirror));
|
||||
if ($matches->count() !== 1) {
|
||||
continue;
|
||||
}
|
||||
$leader = $matches->sole();
|
||||
$contradiction = $independent->contains(fn (BlockedPeriod $other): bool => $other->id !== $mirror->id && $other->id !== $leader->id
|
||||
&& $other->starts_on->lessThan($leader->ends_on) && $other->ends_on->greaterThan($leader->starts_on)
|
||||
&& ! ($mirrors->has($other->id) && $this->sameDates($other, $leader)));
|
||||
if ($contradiction || $bookings->contains(fn ($booking): bool => $booking->arrival->lessThan($leader->ends_on) && $booking->departure->greaterThan($leader->starts_on))) {
|
||||
continue;
|
||||
}
|
||||
$targets[$mirror->id] = $leader;
|
||||
}
|
||||
|
||||
$counts = ['linked' => 0, 'unlinked' => 0];
|
||||
foreach ($blocks as $block) {
|
||||
$leader = $targets[$block->id] ?? null;
|
||||
if ($leader === null) {
|
||||
if ($block->representation_automatic) {
|
||||
$block->forceFill(['representation_automatic' => false, 'is_representation' => false, 'canonical_block_id' => null, 'export_approved' => false,
|
||||
'needs_review' => true, 'review_note' => self::RECHECK_NOTE])->save();
|
||||
$counts['unlinked']++;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
$newLink = ! $block->is_representation || $block->canonical_block_id !== $leader->id;
|
||||
$block->forceFill(['representation_automatic' => true, 'is_representation' => true, 'canonical_block_id' => $leader->id,
|
||||
'needs_review' => false, 'review_note' => self::LINK_NOTE]);
|
||||
if ($block->isDirty()) {
|
||||
$block->save();
|
||||
}
|
||||
$counts['linked'] += (int) $newLink;
|
||||
if ($leader->reviewed_at === null) {
|
||||
if ($leader->channel?->echo_behavior !== ChannelEchoBehavior::Reexports) {
|
||||
$leader->forceFill(['export_approved' => true]);
|
||||
}
|
||||
if ($leader->review_note === self::OVERLAP_NOTE) {
|
||||
$leader->forceFill(['needs_review' => false, 'review_note' => null]);
|
||||
}
|
||||
if ($leader->isDirty()) {
|
||||
$leader->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $counts;
|
||||
});
|
||||
}
|
||||
|
||||
private function isMirror(BlockedPeriod $block): bool
|
||||
{
|
||||
$interpretation = $block->ical_interpretation ?? [];
|
||||
|
||||
return $block->source === 'channel' && $block->channel_id !== null && $block->missing_imports === 0
|
||||
&& $block->occupation_kind === null && $block->guest_id === null && ! $block->is_private
|
||||
&& $block->block_purpose === null && blank($block->block_note) && $block->reviewed_at === null
|
||||
&& $block->origin_channel_id === null && $block->linked_booking_id === null && $block->channel_representations_count === 0
|
||||
&& $block->ical_event_type === 'block' && ($interpretation['matched'] ?? false)
|
||||
&& ($interpretation['representation'] ?? null) === 'additional_block' && ($interpretation['origin_channel_id'] ?? null) === null
|
||||
&& blank($interpretation['fields']['booking_reference'] ?? null) && blank($interpretation['fields']['guest_full_name'] ?? null)
|
||||
&& blank($interpretation['fields']['guest_first_name'] ?? null) && $this->hasCompatibleReview($block);
|
||||
}
|
||||
|
||||
private function isLeader(BlockedPeriod $block): bool
|
||||
{
|
||||
return $block->source === 'channel' && $block->channel_id !== null && ! $block->is_representation
|
||||
&& $block->occupationKind() === OccupationKind::Reservation && $block->ical_event_type === 'portal_reservation'
|
||||
&& $block->missing_imports === 0 && ! $block->is_private && $block->leading_priority > 0
|
||||
&& $block->origin_channel_id === $block->channel_id && ($block->ical_interpretation['matched'] ?? false)
|
||||
&& ($block->ical_interpretation['representation'] ?? null) === 'leading_candidate' && $this->hasCompatibleReview($block);
|
||||
}
|
||||
|
||||
private function hasCompatibleReview(BlockedPeriod $block): bool
|
||||
{
|
||||
return ! $block->needs_review || in_array($block->review_note, [self::OVERLAP_NOTE, self::LINK_NOTE, self::RECHECK_NOTE], true);
|
||||
}
|
||||
|
||||
private function sameDates(BlockedPeriod $first, BlockedPeriod $second): bool
|
||||
{
|
||||
return $first->starts_on->equalTo($second->starts_on) && $first->ends_on->equalTo($second->ends_on);
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,24 @@
|
||||
use App\Mail\ChannelTasksNotification;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Reminds the landlord once about blocking tasks that are still open after the reminder time.
|
||||
* Reminds the landlord about blocking tasks that are still open after the reminder time, and again after
|
||||
* the landlord's reminder interval while they stay open (Settings::reminderIntervalDays(), 0 = only once).
|
||||
*/
|
||||
class RemindChannelTasks
|
||||
{
|
||||
public function handle(): int
|
||||
{
|
||||
$interval = Settings::reminderIntervalDays();
|
||||
|
||||
$tasks = ChannelTask::query()
|
||||
->open()
|
||||
->whereNull('reminded_at')
|
||||
->where(fn (Builder $query) => $query
|
||||
->whereNull('reminded_at')
|
||||
->when($interval > 0, fn (Builder $query) => $query->orWhere('reminded_at', '<=', now()->subDays($interval))))
|
||||
->where('created_at', '<=', now()->subMinutes(config('fewo.channels.task_reminder_after_minutes')))
|
||||
->with('channel')
|
||||
->get();
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Filament\Pages\OccupancyCalendar;
|
||||
use App\Mail\ChannelConflict;
|
||||
use App\Models\Channel;
|
||||
use App\Support\Inbox;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Reports possible double bookings found while importing portal occupations (calendar sync or portal
|
||||
* e-mail). Every conflict lands in the admin inbox once; only conflicts not reported before are e-mailed,
|
||||
* so a lasting overlap does not trigger a mail on every sync. Unread ones are repeated after the landlord's
|
||||
* reminder interval while the overlap persists (App\Support\Inbox).
|
||||
*/
|
||||
class ReportChannelConflicts
|
||||
{
|
||||
public function __construct(private Inbox $inbox) {}
|
||||
|
||||
/**
|
||||
* @param array<string, CarbonInterface> $conflicts description => first night of the portal occupation
|
||||
* @return list<string> the conflicts e-mailed now (new ones and due reminders)
|
||||
*/
|
||||
public function handle(Channel $channel, array $conflicts): array
|
||||
{
|
||||
$new = [];
|
||||
$reminders = [];
|
||||
foreach ($conflicts as $description => $startsOn) {
|
||||
$message = $this->inbox->post(
|
||||
InboxMessageKind::ChannelConflict,
|
||||
$channel->id.':'.sha1($description),
|
||||
'Mögliche Doppelbuchung über '.$channel->name,
|
||||
$description,
|
||||
$channel,
|
||||
OccupancyCalendar::getUrl(['monat' => $startsOn->format('Y-m'), 'wohnung' => $channel->property_id]),
|
||||
);
|
||||
if ($message?->wasRecentlyCreated) {
|
||||
$new[] = $description;
|
||||
} elseif ($message) {
|
||||
$reminders[] = $description;
|
||||
}
|
||||
}
|
||||
|
||||
if ($new !== [] || $reminders !== []) {
|
||||
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new ChannelConflict($channel, $new, $reminders)));
|
||||
}
|
||||
|
||||
return [...$new, ...$reminders];
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@@ -13,6 +14,7 @@ class ResolveChannelOccupation
|
||||
public function handle(BlockedPeriod $block, string $resolution, ?int $targetId = null, ?int $originId = null): BlockedPeriod
|
||||
{
|
||||
return DB::transaction(function () use ($block, $resolution, $targetId, $originId): BlockedPeriod {
|
||||
Property::query()->whereKey($block->property_id)->lockForUpdate()->firstOrFail();
|
||||
$block = BlockedPeriod::query()->whereKey($block->id)->lockForUpdate()->firstOrFail();
|
||||
if (! in_array($block->source, ['channel', 'email'], true)) {
|
||||
throw ValidationException::withMessages(['resolution' => 'Nur importierte Portalereignisse benötigen diese Zuordnung.']);
|
||||
@@ -42,7 +44,8 @@ public function handle(BlockedPeriod $block, string $resolution, ?int $targetId
|
||||
'linked_booking_id' => $resolution === 'booking' ? $target->id : null,
|
||||
'review_note' => 'Persönlich zugeordnet; nur die führende Belegung steuert Verfügbarkeit und Export.'];
|
||||
}
|
||||
$block->update($attributes);
|
||||
$block->forceFill(['representation_automatic' => false])->fill($attributes)->save();
|
||||
app(ReconcileChannelRepresentations::class)->handle($block->property);
|
||||
|
||||
return $block->refresh();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Enums\DigestSection;
|
||||
use App\Mail\Digest;
|
||||
use App\Models\Tenant;
|
||||
use App\Support\DigestReport;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/**
|
||||
* Sends the landlord's daily and/or weekly summary once the chosen hour has come (System › Betrieb ›
|
||||
* Benachrichtigungen). On the weekly day only the weekly summary goes out, never both. Runs per landlord
|
||||
* from the scheduler; the sent dates on the landlord make every summary go out at most once a day.
|
||||
*/
|
||||
class SendDigests
|
||||
{
|
||||
public function __construct(private DigestReport $report) {}
|
||||
|
||||
/**
|
||||
* @return 'daily'|'weekly'|null which summary was due (also when it was skipped for being empty)
|
||||
*/
|
||||
public function handle(Tenant $tenant): ?string
|
||||
{
|
||||
$now = CarbonImmutable::now();
|
||||
$today = $now->startOfDay();
|
||||
if ($now->hour < $tenant->digest_hour) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$weekly = $tenant->digest_weekly && $today->isoWeekday() === $tenant->digest_weekday && ! $tenant->digest_weekly_sent_on?->isSameDay($today);
|
||||
$daily = $tenant->digest_daily && ! $tenant->digest_daily_sent_on?->isSameDay($today);
|
||||
if (! $weekly && ! $daily) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->send($tenant, $weekly);
|
||||
$tenant->forceFill([
|
||||
'digest_daily_sent_on' => $today->toDateString(),
|
||||
...($weekly ? ['digest_weekly_sent_on' => $today->toDateString()] : []),
|
||||
])->save();
|
||||
|
||||
return $weekly ? 'weekly' : 'daily';
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds and mails one summary. Without anything to report it is skipped unless the landlord wants it
|
||||
* anyway or $force is set (button „Zusammenfassung jetzt senden“).
|
||||
*
|
||||
* @return bool whether a mail was sent
|
||||
*/
|
||||
public function send(Tenant $tenant, bool $weekly, bool $force = false): bool
|
||||
{
|
||||
$since = CarbonImmutable::now()->sub($weekly ? '7 days' : '1 day');
|
||||
$sections = $this->report->build(DigestSection::chosen($tenant->digest_sections), $weekly, $since);
|
||||
|
||||
if ($sections === [] && ! $tenant->digest_when_empty && ! $force) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mail::to(Settings::notificationRecipients())->send(new Digest($weekly, $sections));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -6,17 +6,14 @@
|
||||
use App\Channels\ConflictDetector;
|
||||
use App\Channels\ExternalPeriod;
|
||||
use App\Enums\ChannelEchoBehavior;
|
||||
use App\Mail\ChannelConflict;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ChannelSyncLog;
|
||||
use App\Models\Property;
|
||||
use App\Support\Settings;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
/** Imports one complete channel snapshot without guessing that overlapping events are identical. */
|
||||
class SyncChannel
|
||||
@@ -95,21 +92,6 @@ public function handle(Channel $channel): ChannelSyncLog
|
||||
app(ApplyChannelRules::class)->store($block, [...$interpretation, 'ical_properties' => $period->properties, 'ical_raw' => $period->raw]);
|
||||
}
|
||||
$existing->put($period->uid, $block);
|
||||
$overlap = $channel->blockedPeriods()->occupying()->overlapping($block->starts_on, $block->ends_on)->whereKeyNot($block->id)->exists();
|
||||
$foundConflicts = $block->is_representation ? [] : $this->conflictDetector->conflictsFor($block);
|
||||
$linked = $block->canonicalBlock ?? $block->linkedBooking;
|
||||
$linkedStart = $linked instanceof Booking ? $linked->arrival : $linked?->starts_on;
|
||||
$linkedEnd = $linked instanceof Booking ? $linked->departure : $linked?->ends_on;
|
||||
$representationChanged = $block->is_representation && ($linked === null || ! $block->starts_on->equalTo($linkedStart) || ! $block->ends_on->equalTo($linkedEnd));
|
||||
if ($representationChanged || (! $block->is_representation && $block->reviewed_at === null && ($overlap || $emails->isNotEmpty() || $foundConflicts !== [] || ! $block->export_approved))) {
|
||||
$note = 'Mehrere Belegungsrepräsentationen oder Überschneidungen prüfen; keine automatische Zusammenführung anhand von Terminen.';
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
foreach ($emails as $mailBlock) {
|
||||
$mailBlock->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
}
|
||||
$warnings[] = $note;
|
||||
}
|
||||
array_push($conflicts, ...$foundConflicts);
|
||||
}
|
||||
$missing = $rows->filter(fn (BlockedPeriod $block): bool => ! $block->trashed() && ! isset($seen[$block->external_uid]) && $block->ends_on->greaterThan($today));
|
||||
if ($missing->count() > config('channels.max_automatic_removals', 5)) {
|
||||
@@ -128,16 +110,34 @@ public function handle(Channel $channel): ChannelSyncLog
|
||||
}
|
||||
}
|
||||
}
|
||||
app(ReconcileChannelRepresentations::class)->handle($channel->property);
|
||||
foreach ($channel->blockedPeriods()->with(['canonicalBlock', 'linkedBooking'])->where('source', 'channel')->whereIn('external_uid', array_keys($seen))->get() as $block) {
|
||||
$overlap = $channel->blockedPeriods()->occupying()->overlapping($block->starts_on, $block->ends_on)->whereKeyNot($block->id)->exists();
|
||||
$foundConflicts = $block->is_representation ? [] : $this->conflictDetector->conflictsFor($block);
|
||||
$linked = $block->canonicalBlock ?? $block->linkedBooking;
|
||||
$linkedStart = $linked instanceof Booking ? $linked->arrival : $linked?->starts_on;
|
||||
$linkedEnd = $linked instanceof Booking ? $linked->departure : $linked?->ends_on;
|
||||
$representationChanged = $block->is_representation && ($linked === null || ! $block->starts_on->equalTo($linkedStart) || ! $block->ends_on->equalTo($linkedEnd));
|
||||
if ($representationChanged || (! $block->is_representation && $block->reviewed_at === null && ($overlap || $emails->isNotEmpty() || $foundConflicts !== [] || ! $block->export_approved))) {
|
||||
$note = ReconcileChannelRepresentations::OVERLAP_NOTE;
|
||||
$block->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
foreach ($emails as $mailBlock) {
|
||||
$mailBlock->forceFill(['needs_review' => true, 'review_note' => $note])->saveQuietly();
|
||||
}
|
||||
$warnings[] = $note;
|
||||
}
|
||||
foreach ($foundConflicts as $conflict) {
|
||||
$conflicts[$conflict] ??= $block->starts_on;
|
||||
}
|
||||
}
|
||||
$warnings = array_values(array_unique($warnings));
|
||||
$locked->forceFill(['last_synced_at' => now(), 'last_success_at' => now(), 'last_error' => null,
|
||||
'alerted_at' => null, 'last_import_events' => count($periods), 'sync_warnings' => $warnings])->save();
|
||||
});
|
||||
if ($conflicts !== []) {
|
||||
rescue(fn () => Mail::to(Settings::notificationRecipients())->send(new ChannelConflict($channel, array_values(array_unique($conflicts)))));
|
||||
}
|
||||
app(ReportChannelConflicts::class)->handle($channel, $conflicts);
|
||||
|
||||
return $channel->syncLogs()->create(['successful' => true, 'events' => count($periods), ...$counts,
|
||||
'conflicts' => count(array_unique($conflicts)), 'warnings' => $warnings,
|
||||
'conflicts' => count($conflicts), 'warnings' => $warnings,
|
||||
'duration_ms' => (int) round((microtime(true) - $startedAt) * 1000)]);
|
||||
} catch (ChannelSyncException $exception) {
|
||||
$channel->forceFill(['last_synced_at' => now(), 'last_error_at' => now(), 'last_error' => $exception->getMessage()])->save();
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace App\Availability;
|
||||
|
||||
use App\Models\Property;
|
||||
use App\Pricing\PriceCalculator;
|
||||
use App\Pricing\PriceQuote;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
/**
|
||||
* The next bookable stays from tomorrow on, for the "next free dates" in the hero section: free nights
|
||||
* that the PriceCalculator accepts (minimum stay, offers applied), at least $nights long, not overlapping.
|
||||
* Cached briefly per apartment because each candidate is a full price calculation (dates as strings: the cache
|
||||
* does not unserialize objects).
|
||||
*/
|
||||
class NextFreeStays
|
||||
{
|
||||
public const HORIZON_DAYS = 120;
|
||||
|
||||
public const MAX_NIGHTS = 7;
|
||||
|
||||
public function __construct(
|
||||
private AvailabilityChecker $availability,
|
||||
private PriceCalculator $calculator,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return list<array{arrival: CarbonImmutable, departure: CarbonImmutable, nights: int, total: int, url: string}>
|
||||
*/
|
||||
public function for(Property $property, int $count = 3, int $nights = 3, int $guests = 2): array
|
||||
{
|
||||
$key = "next-free-stays:{$property->id}:{$count}:{$nights}:{$guests}:".today()->toDateString();
|
||||
|
||||
$stays = Cache::remember($key, now()->addMinutes(10), fn (): array => $this->find($property, $count, $nights, min($guests, $property->max_guests)));
|
||||
|
||||
return array_map(fn (array $stay): array => [
|
||||
...$stay,
|
||||
'arrival' => CarbonImmutable::parse($stay['arrival']),
|
||||
'departure' => CarbonImmutable::parse($stay['departure']),
|
||||
], $stays);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{arrival: string, departure: string, nights: int, total: int, url: string}>
|
||||
*/
|
||||
private function find(Property $property, int $count, int $nights, int $guests): array
|
||||
{
|
||||
$from = CarbonImmutable::tomorrow();
|
||||
$until = $from->addDays(self::HORIZON_DAYS + self::MAX_NIGHTS);
|
||||
$occupied = $this->availability->occupiedNights($property, $from, $until);
|
||||
$stays = [];
|
||||
|
||||
for ($arrival = $from; count($stays) < $count && $arrival->lessThan($from->addDays(self::HORIZON_DAYS)); $arrival = $arrival->addDay()) {
|
||||
if (isset($occupied[$arrival->toDateString()])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$quote = $this->firstPricedStay($property, $arrival, $nights, $guests, $occupied);
|
||||
if ($quote === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stays[] = [
|
||||
'arrival' => $quote->arrival->toDateString(),
|
||||
'departure' => $quote->departure->toDateString(),
|
||||
'nights' => $quote->nights(),
|
||||
'total' => $quote->total(),
|
||||
'url' => route('booking.create', ['anreise' => $quote->arrival->toDateString(), 'abreise' => $quote->departure->toDateString(), 'personen' => $guests]),
|
||||
];
|
||||
$arrival = $quote->departure->subDay();
|
||||
}
|
||||
|
||||
return $stays;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shortest stay of at least $nights from $arrival that is free and priceable, if any.
|
||||
*
|
||||
* @param array<string, true> $occupied
|
||||
*/
|
||||
private function firstPricedStay(Property $property, CarbonImmutable $arrival, int $nights, int $guests, array $occupied): ?PriceQuote
|
||||
{
|
||||
for ($length = 1; $length <= self::MAX_NIGHTS; $length++) {
|
||||
if (isset($occupied[$arrival->addDays($length - 1)->toDateString()])) {
|
||||
return null;
|
||||
}
|
||||
if ($length < $nights) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->calculator->calculate($property, new StayRequest($arrival, $arrival->addDays($length), $guests));
|
||||
} catch (QuoteException) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ class OccupancyOverview
|
||||
public function records(?int $propertyId = null, ?int $guestId = null, bool $includeBlocks = false, ?CarbonImmutable $from = null, ?CarbonImmutable $until = null): Collection
|
||||
{
|
||||
Gate::authorize('viewAny', Booking::class);
|
||||
$bookings = Booking::query()->with(['guest', 'property', 'originChannel', 'importChannel'])->withCount('channelRepresentations')
|
||||
$representations = ['channelRepresentations' => fn ($query) => $query->select(['id', 'channel_id', 'canonical_block_id', 'linked_booking_id'])->with('channel:id,name')];
|
||||
$bookings = Booking::query()->with(['guest', 'property', 'originChannel', 'importChannel'])->with($representations)->withCount('channelRepresentations')
|
||||
->when($propertyId, fn ($query) => $query->where('property_id', $propertyId))
|
||||
->when($guestId, fn ($query) => $query->where('guest_id', $guestId))
|
||||
->when($from, fn ($query) => $query->whereDate('departure', '>=', $from))
|
||||
@@ -46,11 +47,12 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
|
||||
'occupies' => in_array($booking->status, BookingStatus::occupying(), true) || $booking->isHoldActive(),
|
||||
'needs_review' => false, 'review_note' => null, 'reason' => null, 'archived' => false,
|
||||
'representations' => $booking->channel_representations_count,
|
||||
'mirrored_channels' => $booking->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
|
||||
'url' => BookingResource::getUrl('view', ['record' => $booking->id]),
|
||||
'guest_url' => $booking->guest_id ? GuestResource::getUrl('edit', ['record' => $booking->guest_id]) : null,
|
||||
]);
|
||||
}
|
||||
$blocks = BlockedPeriod::query()->select(['id', 'tenant_id', 'property_id', 'guest_id', 'channel_id', 'origin_channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'occupation_kind', 'block_purpose', 'block_note', 'is_private', 'ical_event_type', 'ical_interpretation', 'is_representation', 'needs_review', 'review_note', 'deleted_at'])->withTrashed()->occupying()->with(['guest', 'property', 'channel', 'originChannel'])->withCount('channelRepresentations')
|
||||
$blocks = BlockedPeriod::query()->select(['id', 'tenant_id', 'property_id', 'guest_id', 'channel_id', 'origin_channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'occupation_kind', 'block_purpose', 'block_note', 'is_private', 'ical_event_type', 'ical_interpretation', 'is_representation', 'needs_review', 'review_note', 'deleted_at'])->withTrashed()->occupying()->with(['guest', 'property', 'channel', 'originChannel'])->with($representations)->withCount('channelRepresentations')
|
||||
->when(! $includeBlocks, fn ($query) => $query->reservations())
|
||||
->when($propertyId, fn ($query) => $query->where('property_id', $propertyId))
|
||||
->when($guestId, fn ($query) => $query->where('guest_id', $guestId)->reservations())
|
||||
@@ -73,6 +75,7 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
|
||||
'status_key' => $block->trashed() ? 'archived' : 'imported', 'color' => $block->needs_review ? 'warning' : $kind->getColor(),
|
||||
'occupies' => ! $block->trashed(), 'needs_review' => $block->needs_review, 'review_note' => $block->review_note, 'reason' => $block->blockDescription(),
|
||||
'archived' => $block->trashed(), 'representations' => $block->channel_representations_count,
|
||||
'mirrored_channels' => $block->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
|
||||
'url' => $block->source === 'manual' ? BlockedPeriodResource::getUrl() : PortalOccupationResource::getUrl('view', ['record' => $block->id]),
|
||||
'guest_url' => $block->guest_id ? GuestResource::getUrl('edit', ['record' => $block->guest_id]) : null,
|
||||
]);
|
||||
|
||||
@@ -30,6 +30,7 @@ enum AdminMode: string implements HasDescription, HasLabel
|
||||
*/
|
||||
public const SIMPLE_NAVIGATION = [
|
||||
OccupancyCalendar::class,
|
||||
InboxMessageResource::class,
|
||||
BookingResource::class,
|
||||
PortalOccupationResource::class,
|
||||
BlockedPeriodResource::class,
|
||||
@@ -52,7 +53,7 @@ public function getLabel(): string
|
||||
public function getDescription(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Simple => 'Das Tägliche: Anfragen, Buchungen und Verträge, Sperrzeiten, Preise & Angebote, Gäste, Kalenderabgleich (iCal), Portal-Aufgaben, Bewertungen, Fotos',
|
||||
self::Simple => 'Das Tägliche: Postfach, Anfragen, Buchungen und Verträge, Sperrzeiten, Preise & Angebote, Gäste, Kalenderabgleich (iCal), Portal-Aufgaben, Bewertungen, Fotos',
|
||||
self::Expert => 'Alle Einstellungen: Preise, Angebote, Kalenderabgleich (iCal), Webseite, System',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasDescription;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* The parts of the daily/weekly summary a landlord can choose (System › Betrieb › Benachrichtigungen).
|
||||
*/
|
||||
enum DigestSection: string implements HasDescription, HasLabel
|
||||
{
|
||||
case Inbox = 'inbox';
|
||||
case Requests = 'requests';
|
||||
case News = 'news';
|
||||
case Stays = 'stays';
|
||||
case Payments = 'payments';
|
||||
case Portals = 'portals';
|
||||
case Reviews = 'reviews';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Inbox => 'Postfach',
|
||||
self::Requests => 'Offene Anfragen und Angebote',
|
||||
self::News => 'Neu seit der letzten Übersicht',
|
||||
self::Stays => 'An- und Abreisen',
|
||||
self::Payments => 'Überfällige Zahlungen',
|
||||
self::Portals => 'Portale: Aufgaben und Klärungsfälle',
|
||||
self::Reviews => 'Bewertungen zur Freigabe',
|
||||
};
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Inbox => 'Ungelesene Meldungen, z. B. mögliche Doppelbuchungen',
|
||||
self::Requests => 'Anfragen und Angebote, die auf Sie oder den Gast warten, mit Frist',
|
||||
self::News => 'Neue Anfragen, Buchungen, Stornierungen und Portalbuchungen',
|
||||
self::Stays => 'Heute und morgen, in der Wochenübersicht die nächsten 7 Tage',
|
||||
self::Payments => 'Anzahlungen und Restzahlungen nach Fälligkeit',
|
||||
self::Portals => 'Offene Portal-Aufgaben, zu prüfende Portal-Mails und Kalendereinträge, Abgleichsfehler',
|
||||
self::Reviews => 'Neue Bewertungen, die noch nicht freigegeben sind',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string>|null $values stored choice; null = everything
|
||||
* @return list<self>
|
||||
*/
|
||||
public static function chosen(?array $values): array
|
||||
{
|
||||
return $values === null ? self::cases() : array_values(array_filter(self::cases(), fn (self $section): bool => in_array($section->value, $values, true)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
/**
|
||||
* What an inbox message is about.
|
||||
*/
|
||||
enum InboxMessageKind: string implements HasColor, HasLabel
|
||||
{
|
||||
case ChannelConflict = 'channel_conflict';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ChannelConflict => 'Mögliche Doppelbuchung',
|
||||
};
|
||||
}
|
||||
|
||||
public function getColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::ChannelConflict => 'danger',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,8 @@ enum PhotoCategory: string implements HasLabel
|
||||
case Apartment = 'apartment';
|
||||
case Outdoor = 'outdoor';
|
||||
case Area = 'area';
|
||||
/** Floor plans and drawings: chosen explicitly (e.g. for the interactive floor plan), never shown in galleries. */
|
||||
case Plan = 'plan';
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
@@ -16,6 +18,17 @@ public function getLabel(): string
|
||||
self::Apartment => 'Wohnung',
|
||||
self::Outdoor => 'Terrasse & Garten',
|
||||
self::Area => 'Kühlungsborn & Umgebung',
|
||||
self::Plan => 'Grundriss & Pläne',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories a gallery or an automatic photo may show.
|
||||
*
|
||||
* @return list<self>
|
||||
*/
|
||||
public static function forGalleries(): array
|
||||
{
|
||||
return array_values(array_filter(self::cases(), fn (self $category): bool => $category !== self::Plan));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Concerns;
|
||||
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
|
||||
/**
|
||||
* Limits a resource list to the apartment chosen in the admin menu (CurrentProperty).
|
||||
* Records stay reachable by URL; opening one switches to its apartment (SelectsRecordProperty).
|
||||
*/
|
||||
trait ListsCurrentProperty
|
||||
{
|
||||
protected function getTableQuery(): Builder|Relation|null
|
||||
{
|
||||
$query = parent::getTableQuery();
|
||||
$property = app(CurrentProperty::class)->get();
|
||||
|
||||
return $query instanceof Builder && $property !== null ? $this->scopeToProperty($query, $property) : $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<Model> $query
|
||||
* @return Builder<Model>
|
||||
*/
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->where($query->qualifyColumn('property_id'), $property->id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Concerns;
|
||||
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Opening a record of another apartment (e.g. from a notification e-mail) switches the admin to that apartment,
|
||||
* so the menu always shows the apartment the open record belongs to.
|
||||
*/
|
||||
trait SelectsRecordProperty
|
||||
{
|
||||
public static function resolveRecordRouteBinding(int|string $key, ?Closure $modifyQuery = null): ?Model
|
||||
{
|
||||
$record = parent::resolveRecordRouteBinding($key, $modifyQuery);
|
||||
$propertyId = $record !== null ? static::recordPropertyId($record) : null;
|
||||
|
||||
if ($propertyId !== null && $propertyId !== app(CurrentProperty::class)->id() && ($property = Property::query()->find($propertyId))) {
|
||||
app(CurrentProperty::class)->select($property);
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
public static function recordPropertyId(Model $record): ?int
|
||||
{
|
||||
$id = $record->getAttribute('property_id');
|
||||
|
||||
return $id !== null ? (int) $id : null;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,8 @@ public static function optionLabel(Photo $photo): string
|
||||
? '<img src="'.e($thumbnail).'" alt="" loading="lazy" style="width:4.5rem;height:3rem;object-fit:cover;border-radius:.25rem;flex-shrink:0">'
|
||||
: '<span style="width:4.5rem;height:3rem;border-radius:.25rem;background:#e5e7eb;flex-shrink:0"></span>';
|
||||
$hidden = $photo->is_published ? '' : ' <em style="opacity:.6">(ausgeblendet)</em>';
|
||||
$seasons = $photo->appearanceNames() === [] ? '' : ' <em style="opacity:.75">· nur '.e(implode(', ', $photo->appearanceNames())).'</em>';
|
||||
|
||||
return '<span style="display:flex;align-items:center;gap:.75rem">'.$image.'<span>'.e($photo->alt_text).$hidden.'</span></span>';
|
||||
return '<span style="display:flex;align-items:center;gap:.75rem">'.$image.'<span>'.e($photo->alt_text).$seasons.$hidden.'</span></span>';
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use BackedEnum;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Filament\Pages\Page;
|
||||
@@ -45,10 +46,15 @@ public static function canAccess(): bool
|
||||
return Gate::allows('viewAny', Booking::class);
|
||||
}
|
||||
|
||||
public function getSubheading(): ?string
|
||||
{
|
||||
return app(CurrentProperty::class)->hasChoice() ? Property::query()->find($this->propertyId)?->name : null;
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->month = $this->month ?: now()->format('Y-m');
|
||||
$this->propertyId ??= Property::query()->where('is_active', true)->value('id') ?? Property::query()->value('id');
|
||||
$this->propertyId = app(CurrentProperty::class)->followUrl($this->propertyId);
|
||||
}
|
||||
|
||||
#[Computed]
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Actions\SendDigests;
|
||||
use App\Enums\DigestSection;
|
||||
use App\Enums\TenantServiceKey;
|
||||
use App\Enums\UserRole;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
@@ -11,10 +13,12 @@
|
||||
use App\Tenancy\TenantFeatures;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
@@ -30,7 +34,7 @@
|
||||
/**
|
||||
* Operating data of the landlord: operating mode (test mode sends every e-mail to one test recipient only;
|
||||
* live delivers to the real recipients), the addresses of the internal communication, the landlord's own
|
||||
* address and bank details, and the periods. Administrators only.
|
||||
* address and bank details, reminders and summaries, and the periods. Administrators only.
|
||||
*/
|
||||
class Operations extends Page
|
||||
{
|
||||
@@ -53,6 +57,11 @@ class Operations extends Page
|
||||
'channel_task_reminder_after_minutes' => 'Erinnerung an Portal-Aufgaben nach (Minuten)',
|
||||
];
|
||||
|
||||
/** Choices for repeating open findings (days => label). */
|
||||
public const REMINDER_INTERVALS = [0 => 'Nur einmal', 1 => 'Täglich', 2 => 'Alle 2 Tage', 3 => 'Alle 3 Tage', 7 => 'Wöchentlich'];
|
||||
|
||||
public const WEEKDAYS = [1 => 'Montag', 2 => 'Dienstag', 3 => 'Mittwoch', 4 => 'Donnerstag', 5 => 'Freitag', 6 => 'Samstag', 7 => 'Sonntag'];
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedPower;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'System';
|
||||
@@ -99,6 +108,13 @@ public function mount(): void
|
||||
'mailbox_password' => $tenant->mailbox_password,
|
||||
'mailbox_encryption' => $tenant->mailbox_encryption,
|
||||
'mailbox_folder' => $tenant->mailbox_folder,
|
||||
'reminder_interval_days' => $tenant->reminder_interval_days,
|
||||
'digest_daily' => $tenant->digest_daily,
|
||||
'digest_weekly' => $tenant->digest_weekly,
|
||||
'digest_weekday' => $tenant->digest_weekday,
|
||||
'digest_hour' => $tenant->digest_hour,
|
||||
'digest_sections' => array_map(fn (DigestSection $section): string => $section->value, DigestSection::chosen($tenant->digest_sections)),
|
||||
'digest_when_empty' => $tenant->digest_when_empty,
|
||||
...$this->periodValues($tenant),
|
||||
]);
|
||||
}
|
||||
@@ -181,6 +197,43 @@ public function form(Schema $schema): Schema
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Benachrichtigungen')
|
||||
->description('Wie oft offene Meldungen wiederholt werden und welche Zusammenfassungen Sie per E-Mail erhalten. Empfänger sind die Adressen unter „Benachrichtigungen an“.')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('reminder_interval_days')
|
||||
->label('Offene Meldungen erneut senden')
|
||||
->helperText('Gilt für mögliche Doppelbuchungen (solange sie im Postfach ungelesen sind und weiter bestehen) und offene Portal-Aufgaben.')
|
||||
->options(self::REMINDER_INTERVALS)
|
||||
->selectablePlaceholder(false)
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Toggle::make('digest_daily')->label('Tägliche Zusammenfassung'),
|
||||
Toggle::make('digest_weekly')->label('Wöchentliche Zusammenfassung')->live(),
|
||||
Select::make('digest_hour')
|
||||
->label('Versand ab')
|
||||
->options(collect(range(5, 21))->mapWithKeys(fn (int $hour): array => [$hour => sprintf('%02d:00 Uhr', $hour)])->all())
|
||||
->selectablePlaceholder(false)
|
||||
->required(),
|
||||
Select::make('digest_weekday')
|
||||
->label('Wochentag der Wochenübersicht')
|
||||
->helperText('An diesem Tag kommt nur die Wochenübersicht, nicht zusätzlich die tägliche.')
|
||||
->options(self::WEEKDAYS)
|
||||
->selectablePlaceholder(false)
|
||||
->visible(fn (Get $get): bool => (bool) $get('digest_weekly'))
|
||||
->required(),
|
||||
CheckboxList::make('digest_sections')
|
||||
->label('Inhalt der Zusammenfassung')
|
||||
->options(DigestSection::class)
|
||||
->descriptions(collect(DigestSection::cases())->mapWithKeys(fn (DigestSection $section): array => [$section->value => $section->getDescription()])->all())
|
||||
->columns(2)
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
Toggle::make('digest_when_empty')
|
||||
->label('Auch senden, wenn nichts ansteht')
|
||||
->helperText('Sonst entfällt die Zusammenfassung an Tagen ohne offene Punkte.')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Portal-Postfach')
|
||||
->description('Aus diesem Postfach werden die Buchungsmails der Portale gelesen, damit ein Termin sofort gesperrt wird. Leerer Server = ausgeschaltet. Das Passwort liegt verschlüsselt in der Datenbank.')
|
||||
->columns(2)
|
||||
@@ -215,6 +268,29 @@ public function content(Schema $schema): Schema
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('sendDigest')
|
||||
->label('Zusammenfassung jetzt senden')
|
||||
->icon(Heroicon::OutlinedPaperAirplane)
|
||||
->color('gray')
|
||||
->modalDescription('Schickt die Zusammenfassung mit den gespeicherten Einstellungen sofort an die Benachrichtigungsadressen – auch wenn nichts ansteht. Der reguläre Versand bleibt unverändert.')
|
||||
->schema([
|
||||
Radio::make('weekly')
|
||||
->label('Welche?')
|
||||
->options([0 => 'Tagesübersicht', 1 => 'Wochenübersicht'])
|
||||
->default(0)
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
app(SendDigests::class)->send($this->tenant(), (bool) $data['weekly'], force: true);
|
||||
|
||||
Notification::make()->title('Zusammenfassung gesendet')->body(Settings::isLive() ? null : 'Testbetrieb: Sie geht an die Testadresse.')->success()->send();
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
$data = $this->form->getState();
|
||||
@@ -243,6 +319,13 @@ public function save(): void
|
||||
'mailbox_password' => $data['mailbox_password'] ?? null,
|
||||
'mailbox_encryption' => $data['mailbox_encryption'] ?? null,
|
||||
'mailbox_folder' => $data['mailbox_folder'] ?? null,
|
||||
'reminder_interval_days' => (int) $data['reminder_interval_days'],
|
||||
'digest_daily' => (bool) $data['digest_daily'],
|
||||
'digest_weekly' => (bool) $data['digest_weekly'],
|
||||
'digest_weekday' => (int) ($data['digest_weekday'] ?? $tenant->digest_weekday),
|
||||
'digest_hour' => (int) $data['digest_hour'],
|
||||
'digest_sections' => count($data['digest_sections']) === count(DigestSection::cases()) ? null : array_values($data['digest_sections']),
|
||||
'digest_when_empty' => (bool) $data['digest_when_empty'],
|
||||
...array_map(fn (mixed $value): ?int => filled($value) ? (int) $value : null, $this->periodInput($data)),
|
||||
]);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
|
||||
use App\Filament\Resources\Properties\RelationManagers\SpecialOffersRelationManager;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use BackedEnum;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Schemas\Components\Livewire;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
@@ -49,9 +49,14 @@ public static function canAccess(): bool
|
||||
return (bool) auth()->user()?->hasRole(UserRole::Admin, UserRole::Rentals);
|
||||
}
|
||||
|
||||
public function getSubheading(): ?string
|
||||
{
|
||||
return app(CurrentProperty::class)->hasChoice() ? Property::query()->find($this->propertyId)?->name : null;
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->propertyId ??= Property::query()->where('is_active', true)->value('id') ?? Property::query()->value('id');
|
||||
$this->propertyId = app(CurrentProperty::class)->followUrl($this->propertyId);
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
@@ -64,12 +69,6 @@ public function content(Schema $schema): Schema
|
||||
$context = ['ownerRecord' => $property, 'pageClass' => EditProperty::class];
|
||||
|
||||
return $schema->components([
|
||||
Select::make('propertyId')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->live()
|
||||
->afterStateUpdated(fn () => $this->redirect(static::getUrl(['wohnung' => $this->propertyId])))
|
||||
->visible(fn (): bool => Property::query()->count() > 1),
|
||||
Tabs::make('prices')
|
||||
->persistTabInQueryString()
|
||||
->tabs([
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Amenities;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Amenities\Pages\CreateAmenity;
|
||||
use App\Filament\Resources\Amenities\Pages\EditAmenity;
|
||||
use App\Filament\Resources\Amenities\Pages\ListAmenities;
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
class AmenityResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Amenity::class;
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Amenities\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\Amenities\AmenityResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAmenities extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = AmenityResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\AmenityArea;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
@@ -28,7 +29,7 @@ public static function configure(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->required(),
|
||||
Toggle::make('is_highlight')
|
||||
->label('Highlight (auf der Startseite hervorheben)'),
|
||||
|
||||
@@ -2,21 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Appearances\Schemas;
|
||||
|
||||
use App\Filament\Forms\Components\PhotoSelect;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Page;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Site;
|
||||
use App\Themes\SectionRegistry;
|
||||
use App\Themes\Sections\Section as SectionBlock;
|
||||
use App\Themes\ThemeRegistry;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\ColorPicker;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
@@ -45,20 +39,13 @@ public static function configure(Schema $schema): Schema
|
||||
Toggle::make('is_default')->label('Standard (wenn kein Zeitraum passt)')->inline(false),
|
||||
Toggle::make('is_active')->label('Aktiv')->default(true)->inline(false),
|
||||
]),
|
||||
Section::make('Titelbild')
|
||||
->description('Gilt für alle Titelbereiche und als Vorschaubild beim Teilen in sozialen Medien – einzelne Bausteine können unten ein eigenes Bild bekommen. Sonderangebote werden unabhängig vom Erscheinungsbild beworben (Wohnung › Sonderangebote).')
|
||||
Section::make('Bilder')
|
||||
->description('Welche Fotos in diesem Erscheinungsbild erscheinen, legen Sie beim Foto fest: Webseite › Fotos › „Zeigen in“. Ein Foto kann zu mehreren Erscheinungsbildern gehören; Fotos ohne Angabe erscheinen ganzjährig.')
|
||||
->schema([
|
||||
PhotoSelect::make('hero_photo_id')
|
||||
->label('Titelbild')
|
||||
->placeholder('Bild der Seite verwenden'),
|
||||
Text::make(fn (?Appearance $record): string => self::photoSummary($record)),
|
||||
]),
|
||||
Section::make('Bilder je Baustein')
|
||||
->description('Für jeden Baustein mit Bildern ein eigenes Saisonbild wählen. Leer = Bild aus der Seite. Neue Bilder laden Sie unter Webseite › Fotos hoch.')
|
||||
->collapsible()
|
||||
->columnSpanFull()
|
||||
->schema(fn (Get $get): array => self::sectionPhotoFields($get('site_id'))),
|
||||
Section::make('Texte')
|
||||
->description('Leer lassen = Text der Seite bzw. kein Banner.')
|
||||
->description('Leer lassen = Text der Seite. Banner pflegen Sie unter Webseite › Banner & Hinweise – dort auch nur für dieses Erscheinungsbild.')
|
||||
->columns(2)
|
||||
->collapsible()
|
||||
->schema(collect(Appearance::OVERRIDABLE)
|
||||
@@ -75,57 +62,21 @@ public static function configure(Schema $schema): Schema
|
||||
}
|
||||
|
||||
/**
|
||||
* One group per page and one field set per placed section that has photo slots
|
||||
* (see Section::photoSlots); stored in section_photos[<section id>][<slot>].
|
||||
*
|
||||
* @return list<Component>
|
||||
* How many photos are made for this appearance.
|
||||
*/
|
||||
public static function sectionPhotoFields(int|string|null $siteId): array
|
||||
public static function photoSummary(?Appearance $appearance): string
|
||||
{
|
||||
$registry = app(SectionRegistry::class);
|
||||
$pages = Page::query()->where('site_id', $siteId)->orderBy('sort_order')->get();
|
||||
|
||||
$groups = [];
|
||||
foreach ($pages as $page) {
|
||||
$fieldsets = [];
|
||||
foreach ($page->sections ?? [] as $stored) {
|
||||
$class = $registry->all()[$stored['type'] ?? ''] ?? null;
|
||||
$sectionId = $stored['data']['id'] ?? null;
|
||||
if ($class === null || blank($sectionId) || $class::photoSlots() === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$fields = [];
|
||||
foreach ($class::photoSlots() as $slot => $definition) {
|
||||
$field = PhotoSelect::make("section_photos.{$sectionId}.{$slot}")
|
||||
->label($definition['label'])
|
||||
->placeholder('Standard (Bild aus der Seite)')
|
||||
->multiple($definition['type'] !== SectionBlock::SLOT_SINGLE);
|
||||
if (isset($definition['max'])) {
|
||||
$field->maxItems($definition['max']);
|
||||
}
|
||||
$fields[] = $field;
|
||||
|
||||
if ($definition['type'] === SectionBlock::SLOT_COLLECTION) {
|
||||
$fields[] = Radio::make("section_photos.{$sectionId}.mode")
|
||||
->label('Saisonbilder')
|
||||
->options(['replace' => 'ersetzen die Bilder des Bausteins', 'prepend' => 'kommen zuerst, danach die übrigen'])
|
||||
->default('replace')
|
||||
->inline();
|
||||
}
|
||||
}
|
||||
|
||||
$fieldsets[] = Fieldset::make(collect([$class::label(), $class::summary($stored['data'] ?? [])])->filter()->implode(' · '))
|
||||
->columns(1)
|
||||
->schema($fields);
|
||||
}
|
||||
|
||||
if ($fieldsets !== []) {
|
||||
$groups[] = Section::make($page->title)->compact()->collapsible()->schema($fieldsets);
|
||||
}
|
||||
if ($appearance === null) {
|
||||
return 'Nach dem Speichern können Sie Fotos diesem Erscheinungsbild zuordnen.';
|
||||
}
|
||||
|
||||
return $groups ?: [Text::make('Auf den Seiten gibt es noch keine Bausteine mit Bildern.')];
|
||||
$count = Photo::query()->get(['id', 'appearance_ids'])->filter(fn (Photo $photo): bool => $photo->isMadeFor($appearance))->count();
|
||||
|
||||
return match ($count) {
|
||||
0 => 'Noch keine Fotos zugeordnet – es erscheinen die ganzjährigen Fotos.',
|
||||
1 => '1 Foto ist diesem Erscheinungsbild zugeordnet.',
|
||||
default => "{$count} Fotos sind diesem Erscheinungsbild zugeordnet.",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,12 +6,14 @@
|
||||
use App\Channels\ICal\ICalRuleEngine;
|
||||
use App\Enums\BlockedPeriodPurpose;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\BlockedPeriods\Pages\ManageBlockedPeriods;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
@@ -37,7 +39,7 @@
|
||||
*/
|
||||
class BlockedPeriodResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = BlockedPeriod::class;
|
||||
|
||||
@@ -59,7 +61,7 @@ public static function form(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->where('is_active', true)->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->required()
|
||||
->columnSpanFull()
|
||||
->hidden(fn (): bool => Property::query()->count() <= 1)
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\BlockedPeriods\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageBlockedPeriods extends ManageRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = BlockedPeriodResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Bookings\Pages\CreateBooking;
|
||||
use App\Filament\Resources\Bookings\Pages\ListBookings;
|
||||
use App\Filament\Resources\Bookings\Pages\ViewBooking;
|
||||
@@ -21,7 +22,7 @@
|
||||
|
||||
class BookingResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Booking::class;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Bookings\Schemas;
|
||||
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -26,7 +27,7 @@ public static function configure(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->required(),
|
||||
TextInput::make('guests')
|
||||
->label('Personen')
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Availability\OccupancyOverview;
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
@@ -59,7 +60,9 @@ public static function configure(Table $table, ?int $guestId = null): Table
|
||||
TextColumn::make('property')->label('Wohnung')->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('property')->label('Wohnung')->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
SelectFilter::make('property')->label('Wohnung')->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
// The booking list starts with the apartment chosen in the menu; a guest's bookings show all apartments.
|
||||
->default(fn (): ?int => $guestId === null ? app(CurrentProperty::class)->id() : null),
|
||||
SelectFilter::make('kind')->label('Buchungsweg')->options(['booking' => 'Eigene Anfragen & Buchungen', 'portal' => 'Portalreservierungen']),
|
||||
SelectFilter::make('status')->label('Status')->multiple()->options([
|
||||
...collect(BookingStatus::cases())->mapWithKeys(fn (BookingStatus $status): array => [$status->value => $status->getLabel()])->all(),
|
||||
|
||||
@@ -2,10 +2,20 @@
|
||||
|
||||
namespace App\Filament\Resources\ChannelTasks\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Models\Property;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListChannelTasks extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = ChannelTaskResource::class;
|
||||
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->whereHas('channel', fn (Builder $channel) => $channel->where('property_id', $property->id));
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Channels;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Channels\Pages\ChannelRules;
|
||||
use App\Filament\Resources\Channels\Pages\CreateChannel;
|
||||
use App\Filament\Resources\Channels\Pages\EditChannel;
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
class ChannelResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Channel::class;
|
||||
|
||||
|
||||
@@ -73,7 +73,8 @@ public function form(Schema $schema): Schema
|
||||
])->columnSpanFull(),
|
||||
Select::make('event_type')->label('Dann: Ereignistyp')->options(ICalRuleEngine::TYPES)->default('unknown')->required(),
|
||||
Select::make('origin')->label('Ursprünglicher Buchungskanal')->options(fn (): array => ['unknown' => 'Unbekannt', 'current' => 'Dieser Portalkanal', ...$this->record->property->channels()->get()->mapWithKeys(fn (Channel $channel): array => ['channel:'.$channel->id => $channel->name])->all()])->default('unknown')->required(),
|
||||
Select::make('representation')->label('Fachliche Einordnung')->options(ICalRuleEngine::REPRESENTATIONS)->default('unspecified')->required()->columnSpanFull(),
|
||||
Select::make('representation')->label('Fachliche Einordnung')->options(ICalRuleEngine::REPRESENTATIONS)->default('unspecified')->required()->columnSpanFull()
|
||||
->helperText('Eine allgemeine Sperre mit „Zusätzliche Sperre“ und unbekanntem Ursprung kann automatisch einer eindeutigen führenden Portalreservierung desselben Zeitraums zugeordnet werden. Eigene Buchungsmerkmale und persönliche Entscheidungen verhindern dies.'),
|
||||
Repeater::make('extractions')->label('Informationen aus Text übernehmen')
|
||||
->helperText('Ein Name im Original wird erst mit einer Textextraktion angezeigt. Für einen vollständigen Namen das passende Kalenderfeld und „Vollständiger Gastname“ wählen. Die Vorschau prüft das Ergebnis; es wird kein Gast automatisch angelegt.')
|
||||
->defaultItems(0)->addActionLabel('Textextraktion hinzufügen')->columns(2)->schema([
|
||||
@@ -202,7 +203,7 @@ protected function getHeaderActions(): array
|
||||
$this->record->refresh();
|
||||
$this->rememberData();
|
||||
Notification::make()->title($counts['classified'].' Einträge neu klassifiziert')
|
||||
->body($counts['missing_raw'].' Einträge ohne Originaldaten unverändert. Zeitgleiche Einträge anderer Kalender bleiben bis zur ausdrücklichen Zuordnung getrennt.')
|
||||
->body($counts['missing_raw'].' Einträge ohne Originaldaten unverändert. Eindeutige allgemeine Belegtmeldungen werden als Kalenderspiegelung zugeordnet; widersprüchliche Einträge bleiben zur Klärung sichtbar.')
|
||||
->success()->send();
|
||||
}),
|
||||
Action::make('configuration')->label('Kalenderverbindung')->url(fn (): string => ChannelResource::getUrl('edit', ['record' => $this->record])),
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Channels\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\Channels\ChannelResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListChannels extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = ChannelResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use App\Enums\ChannelStatus;
|
||||
use App\Models\Channel;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\DateTimePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -30,7 +31,7 @@ public static function configure(Schema $schema, bool $selectProperty = false):
|
||||
->components([
|
||||
...($selectProperty ? [Select::make('property_id')->label('Wohnung')->required()
|
||||
->options(fn (): array => Property::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->where('is_active', true)->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->disabled(fn (?Channel $record): bool => $record !== null)->dehydrated()->columnSpanFull()] : []),
|
||||
TextEntry::make('export_url')
|
||||
->label('Eigener iCal-Exportlink')
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\FloorPlans;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\FloorPlans\Pages\CreateFloorPlan;
|
||||
use App\Filament\Resources\FloorPlans\Pages\EditFloorPlan;
|
||||
use App\Filament\Resources\FloorPlans\Pages\ListFloorPlans;
|
||||
@@ -21,7 +22,7 @@
|
||||
*/
|
||||
class FloorPlanResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = FloorPlan::class;
|
||||
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\FloorPlans\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\FloorPlans\FloorPlanResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListFloorPlans extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = FloorPlanResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Models\Amenity;
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -28,14 +29,14 @@ public static function configure(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->unique(ignoreRecord: true)
|
||||
->validationMessages(['unique' => 'Für diese Wohnung gibt es schon einen Grundriss.'])
|
||||
->required()
|
||||
->live(),
|
||||
PhotoSelect::make('photo_id')
|
||||
->label('Grundriss-Bild')
|
||||
->helperText('Rendering oder Plan aus Webseite › Fotos. Ein neues Bild im gleichen Ausschnitt behält die Räume.')
|
||||
->helperText('Rendering oder Plan aus Webseite › Fotos – am besten in der Kategorie „Grundriss & Pläne“: Sie erscheint in keiner Galerie, ausblenden ist nicht nötig. Ein neues Bild im gleichen Ausschnitt behält die Räume.')
|
||||
->required()
|
||||
->live(),
|
||||
Repeater::make('rooms')
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InboxMessages;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Resources\InboxMessages\Pages\ListInboxMessages;
|
||||
use App\Filament\Resources\InboxMessages\Tables\InboxMessagesTable;
|
||||
use App\Models\InboxMessage;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* The admin inbox ("Postfach"): findings the landlord has to look at, each posted once (App\Support\Inbox).
|
||||
*/
|
||||
class InboxMessageResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
|
||||
protected static ?string $model = InboxMessage::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedInbox;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Vermietung';
|
||||
|
||||
protected static ?string $navigationLabel = 'Postfach';
|
||||
|
||||
protected static ?string $modelLabel = 'Meldung';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Postfach';
|
||||
|
||||
protected static ?int $navigationSort = 0;
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return InboxMessagesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
$unread = InboxMessage::query()->unread()->count();
|
||||
|
||||
return $unread > 0 ? (string) $unread : null;
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): string
|
||||
{
|
||||
return 'danger';
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeTooltip(): ?string
|
||||
{
|
||||
return 'Ungelesen';
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListInboxMessages::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InboxMessages\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\InboxMessages\InboxMessageResource;
|
||||
use App\Models\Property;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListInboxMessages extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = InboxMessageResource::class;
|
||||
|
||||
/**
|
||||
* Messages of the chosen apartment and those that concern no apartment in particular.
|
||||
*/
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->where(fn (Builder $query) => $query->where('property_id', $property->id)->orWhereNull('property_id'));
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('readAll')
|
||||
->label('Alle als gelesen markieren')
|
||||
->icon(Heroicon::OutlinedCheck)
|
||||
->color('gray')
|
||||
->visible(fn (): bool => $this->getTableQuery()->unread()->exists())
|
||||
->action(fn () => $this->getTableQuery()->unread()->update(['read_at' => now()])),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\InboxMessages\Tables;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Models\InboxMessage;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class InboxMessagesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->description('Hinweise, um die Sie sich kümmern sollten. Jede Meldung kommt nur einmal – auch wenn sie bei jedem Kalenderabgleich wieder auffällt.')
|
||||
->emptyStateHeading('Keine Meldungen')
|
||||
->columns([
|
||||
IconColumn::make('read_at')
|
||||
->label('')
|
||||
->state(fn (InboxMessage $record): bool => ! $record->isRead())
|
||||
->boolean()
|
||||
->trueIcon(Heroicon::Envelope)
|
||||
->falseIcon(Heroicon::OutlinedEnvelopeOpen)
|
||||
->trueColor('danger')
|
||||
->falseColor('gray')
|
||||
->tooltip(fn (InboxMessage $record): string => $record->isRead() ? 'Gelesen' : 'Ungelesen'),
|
||||
TextColumn::make('created_at')->label('Eingang')->dateTime('d.m. H:i')->sortable(),
|
||||
TextColumn::make('kind')->label('Art')->badge(),
|
||||
TextColumn::make('subject')
|
||||
->label('Meldung')
|
||||
->weight(fn (InboxMessage $record): ?FontWeight => $record->isRead() ? null : FontWeight::Bold)
|
||||
->description(fn (InboxMessage $record): string => $record->body)
|
||||
->wrap(),
|
||||
])
|
||||
->filters([
|
||||
TernaryFilter::make('read_at')
|
||||
->label('Gelesen')
|
||||
->nullable()
|
||||
->trueLabel('Nur gelesene')
|
||||
->falseLabel('Nur ungelesene'),
|
||||
SelectFilter::make('kind')->label('Art')->options(InboxMessageKind::class),
|
||||
])
|
||||
->recordUrl(null)
|
||||
->recordActions([
|
||||
Action::make('open')
|
||||
->label('Ansehen')
|
||||
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
|
||||
->visible(fn (InboxMessage $record): bool => filled($record->action_url))
|
||||
->action(function (InboxMessage $record) {
|
||||
$record->update(['read_at' => $record->read_at ?? now()]);
|
||||
|
||||
return redirect($record->action_url);
|
||||
}),
|
||||
Action::make('toggleRead')
|
||||
->label(fn (InboxMessage $record): string => $record->isRead() ? 'Als ungelesen markieren' : 'Als gelesen markieren')
|
||||
->icon(fn (InboxMessage $record): Heroicon => $record->isRead() ? Heroicon::OutlinedEnvelope : Heroicon::OutlinedCheck)
|
||||
->color('gray')
|
||||
->action(fn (InboxMessage $record) => $record->update(['read_at' => $record->isRead() ? null : now()])),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('markRead')
|
||||
->label('Als gelesen markieren')
|
||||
->icon(Heroicon::OutlinedCheck)
|
||||
->action(fn (Collection $records) => InboxMessage::query()->whereKey($records->modelKeys())->update(['read_at' => now()]))
|
||||
->deselectRecordsAfterCompletion(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@
|
||||
use App\Filament\Resources\Notices\Schemas\NoticeForm;
|
||||
use App\Filament\Resources\Notices\Tables\NoticesTable;
|
||||
use App\Models\Notice;
|
||||
use App\Models\Site;
|
||||
use App\Tenancy\TenantContext;
|
||||
use App\Themes\Banner;
|
||||
use App\Themes\ThemeFactory;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
@@ -26,9 +30,9 @@ class NoticeResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
|
||||
|
||||
protected static ?string $modelLabel = 'Hinweis';
|
||||
protected static ?string $modelLabel = 'Banner';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Hinweis-Banner';
|
||||
protected static ?string $pluralModelLabel = 'Banner & Hinweise';
|
||||
|
||||
protected static ?int $navigationSort = 6;
|
||||
|
||||
@@ -49,6 +53,31 @@ public static function getRelations(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* The banner each website shows today (none = null), with the website.
|
||||
*
|
||||
* @return list<array{site: Site, banner: Banner|null}>
|
||||
*/
|
||||
public static function bannersToday(): array
|
||||
{
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
// once() keys its cache by the variables the closure uses, so each landlord gets its own entry.
|
||||
return once(function () use ($tenantId): array {
|
||||
return Site::query()->when($tenantId, fn ($query) => $query->where('tenant_id', $tenantId))->orderBy('name')->get()
|
||||
->map(fn (Site $site): array => ['site' => $site, 'banner' => app(ThemeFactory::class)->forSite($site)->banner()])
|
||||
->all();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function noticeIdsShownToday(): array
|
||||
{
|
||||
return collect(self::bannersToday())->pluck('banner')->filter()->map(fn (Banner $banner): int => $banner->notice->id)->unique()->values()->all();
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -10,6 +10,23 @@ class ListNotices extends ListRecords
|
||||
{
|
||||
protected static string $resource = NoticeResource::class;
|
||||
|
||||
/**
|
||||
* Which banner the website shows today – the answer to "why do I see this banner?".
|
||||
*/
|
||||
public function getSubheading(): ?string
|
||||
{
|
||||
$today = NoticeResource::bannersToday();
|
||||
if ($today === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return collect($today)->map(function (array $entry) use ($today): string {
|
||||
$prefix = count($today) > 1 ? $entry['site']->name.': ' : '';
|
||||
|
||||
return $prefix.($entry['banner'] ? 'Heute sichtbar: „'.$entry['banner']->text.'“' : 'Heute ist kein Banner sichtbar.');
|
||||
})->implode(' · ');
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -3,10 +3,17 @@
|
||||
namespace App\Filament\Resources\Notices\Schemas;
|
||||
|
||||
use App\Enums\NoticeTone;
|
||||
use App\Filament\Resources\Photos\Schemas\PhotoForm;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Property;
|
||||
use App\Models\Site;
|
||||
use App\Models\SpecialOffer;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class NoticeForm
|
||||
@@ -14,36 +21,87 @@ 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),
|
||||
Section::make('Inhalt')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('special_offer_id')
|
||||
->label('Sonderangebot bewerben (optional)')
|
||||
->options(fn (): array => self::offerOptions())
|
||||
->placeholder('– kein Angebot –')
|
||||
->searchable()
|
||||
->live()
|
||||
->helperText('Mit Angebot kommen Text, Termin und Link aus dem Angebot, und das Banner erscheint nur, solange die Website das Angebot bewirbt – bei festen Terminen also nur, solange sie frei sind.')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('text')
|
||||
->label('Text')
|
||||
->placeholder(fn (Get $get): string => filled($get('special_offer_id')) ? 'leer = Text aus dem Angebot' : 'z. B. Kurzfristig frei: 12.–15.11. mit 15 % Rabatt')
|
||||
->required(fn (Get $get): bool => blank($get('special_offer_id')))
|
||||
->maxLength(255)
|
||||
->columnSpanFull(),
|
||||
TextInput::make('link_label')
|
||||
->label('Link-Text (optional)')
|
||||
->placeholder(fn (Get $get): string => filled($get('special_offer_id')) ? 'Zum Angebot' : 'z. B. Jetzt anfragen')
|
||||
->maxLength(100),
|
||||
TextInput::make('link_url')
|
||||
->label('Link-Ziel (optional)')
|
||||
->placeholder(fn (Get $get): string => filled($get('special_offer_id')) ? 'Buchung mit den Angebotsterminen' : '/buchen')
|
||||
->maxLength(255),
|
||||
Select::make('tone')
|
||||
->label('Art')
|
||||
->options(NoticeTone::class)
|
||||
->default(NoticeTone::Info)
|
||||
->required(),
|
||||
]),
|
||||
Section::make('Wann und wo')
|
||||
->description('Es erscheint immer nur ein Banner: Gelten mehrere gleichzeitig, gewinnt die höchste Priorität, bei Gleichstand das neueste.')
|
||||
->columns(2)
|
||||
->schema([
|
||||
Select::make('site_id')
|
||||
->label('Website')
|
||||
->options(fn (): array => Site::query()->pluck('name', 'id')->all())
|
||||
->placeholder('alle Websites')
|
||||
->visible(fn (): bool => Site::query()->count() > 1),
|
||||
Select::make('appearance_ids')
|
||||
->label('Nur in Erscheinungsbildern')
|
||||
->multiple()
|
||||
->options(fn (): array => Appearance::photoOptions())
|
||||
->placeholder('immer')
|
||||
->helperText('Leer = in jedem Erscheinungsbild, z. B. Weihnachten und Silvester für ein Festtagsbanner.')
|
||||
->dehydrateStateUsing(fn (?array $state): ?array => PhotoForm::appearanceIds($state)),
|
||||
DatePicker::make('starts_on')
|
||||
->label('Anzeigen ab (optional)'),
|
||||
DatePicker::make('ends_on')
|
||||
->label('Anzeigen bis (optional)')
|
||||
->afterOrEqual('starts_on'),
|
||||
TextInput::make('priority')
|
||||
->label('Priorität')
|
||||
->integer()
|
||||
->minValue(0)
|
||||
->maxValue(999)
|
||||
->default(10)
|
||||
->required(),
|
||||
Toggle::make('is_active')
|
||||
->label('Aktiv')
|
||||
->default(true)
|
||||
->inline(false),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offers the website can advertise (public, without a code), named with their apartment when there are several.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function offerOptions(): array
|
||||
{
|
||||
$severalProperties = Property::query()->count() > 1;
|
||||
|
||||
return SpecialOffer::query()->with('property')->where('is_public', true)->whereNull('code')->orderBy('name')->get()
|
||||
->mapWithKeys(fn (SpecialOffer $offer): array => [$offer->id => $offer->name
|
||||
.($severalProperties ? ' · '.$offer->property?->name : '')
|
||||
.($offer->is_active ? '' : ' (inaktiv)')])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Notices\Tables;
|
||||
|
||||
use App\Filament\Resources\Notices\NoticeResource;
|
||||
use App\Models\Notice;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
@@ -13,14 +16,33 @@ class NoticesTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('starts_on', 'desc')
|
||||
->defaultSort('priority', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('text')->label('Hinweis')->wrap()->searchable(),
|
||||
TextColumn::make('tone')->label('Art')->badge(),
|
||||
IconColumn::make('shown_today')
|
||||
->label('Heute')
|
||||
->state(fn (Notice $record): bool => in_array($record->id, NoticeResource::noticeIdsShownToday(), true))
|
||||
->boolean()
|
||||
->trueIcon('heroicon-s-eye')
|
||||
->falseIcon('heroicon-o-minus')
|
||||
->tooltip(fn (bool $state): string => $state ? 'Wird heute auf der Website gezeigt' : 'Heute nicht sichtbar'),
|
||||
TextColumn::make('text')
|
||||
->label('Banner')
|
||||
->state(fn (Notice $record): string => filled($record->text) ? $record->text : 'Text aus dem Angebot')
|
||||
->description(fn (Notice $record): ?string => $record->specialOffer ? 'Angebot: '.$record->specialOffer->name : null)
|
||||
->wrap()
|
||||
->searchable(),
|
||||
TextColumn::make('appearance_ids')
|
||||
->label('Erscheinungsbilder')
|
||||
->state(fn (Notice $record): array => $record->appearanceNames())
|
||||
->badge()
|
||||
->placeholder('immer'),
|
||||
TextColumn::make('site.name')->label('Website')->placeholder('alle')->toggleable(isToggledHiddenByDefault: true),
|
||||
TextColumn::make('starts_on')->label('Ab')->date('d.m.Y')->placeholder('sofort'),
|
||||
TextColumn::make('ends_on')->label('Bis')->date('d.m.Y')->placeholder('unbegrenzt'),
|
||||
TextColumn::make('priority')->label('Priorität')->sortable(),
|
||||
ToggleColumn::make('is_active')->label('Aktiv'),
|
||||
])
|
||||
->modifyQueryUsing(fn ($query) => $query->with(['specialOffer', 'site']))
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
namespace App\Filament\Resources\Photos\Pages;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\Photos\PhotoResource;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
@@ -13,12 +15,23 @@
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
class ListPhotos extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = PhotoResource::class;
|
||||
|
||||
/**
|
||||
* Photos without an apartment (e.g. the area) belong to every apartment.
|
||||
*/
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->where(fn (Builder $query) => $query->where('property_id', $property->id)->orWhereNull('property_id'));
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -42,7 +55,7 @@ protected function getHeaderActions(): array
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$propertyId = Property::query()->value('id');
|
||||
$propertyId = app(CurrentProperty::class)->id();
|
||||
$nextSort = (int) Photo::max('sort_order');
|
||||
|
||||
/** @var TemporaryUploadedFile $file */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\Photos;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Photos\Pages\CreatePhoto;
|
||||
use App\Filament\Resources\Photos\Pages\EditPhoto;
|
||||
use App\Filament\Resources\Photos\Pages\ListPhotos;
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
class PhotoResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Photo::class;
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
namespace App\Filament\Resources\Photos\Schemas;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -44,11 +46,31 @@ public static function configure(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->placeholder('– keine (z. B. Umgebung) –'),
|
||||
Select::make('appearance_ids')
|
||||
->label('Zeigen in')
|
||||
->multiple()
|
||||
->options(fn (): array => Appearance::photoOptions())
|
||||
->placeholder('ganzjährig')
|
||||
->helperText('Leer = ganzjährig. Mit Auswahl erscheint das Foto nur in diesen Erscheinungsbildern – dann vor den ganzjährigen Fotos.')
|
||||
->dehydrateStateUsing(fn (?array $state): ?array => self::appearanceIds($state)),
|
||||
Toggle::make('is_published')
|
||||
->label('Auf der Webseite zeigen')
|
||||
->default(true),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selected appearances as integers, null for "all year".
|
||||
*
|
||||
* @param array<int|string>|null $state
|
||||
* @return list<int>|null
|
||||
*/
|
||||
public static function appearanceIds(?array $state): ?array
|
||||
{
|
||||
$ids = array_values(array_unique(array_map('intval', array_filter((array) $state))));
|
||||
|
||||
return $ids === [] ? null : $ids;
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,23 @@
|
||||
namespace App\Filament\Resources\Photos\Tables;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Filament\Resources\Photos\Schemas\PhotoForm;
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Photo;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
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;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class PhotosTable
|
||||
{
|
||||
@@ -36,6 +42,12 @@ public static function configure(Table $table): Table
|
||||
->searchable(),
|
||||
TextColumn::make('category')
|
||||
->badge(),
|
||||
TextColumn::make('appearance_ids')
|
||||
->label('Zeigen in')
|
||||
->state(fn (Photo $record): array => $record->appearanceNames())
|
||||
->badge()
|
||||
->color('warning')
|
||||
->icon('heroicon-m-sun'),
|
||||
IconColumn::make('is_published')
|
||||
->boolean()
|
||||
->trueIcon('heroicon-o-eye')
|
||||
@@ -46,6 +58,14 @@ public static function configure(Table $table): Table
|
||||
SelectFilter::make('category')
|
||||
->label('Kategorie')
|
||||
->options(PhotoCategory::class),
|
||||
SelectFilter::make('season')
|
||||
->label('Zeigen in')
|
||||
->options(fn (): array => ['all_year' => 'ganzjährig', ...Appearance::photoOptions()])
|
||||
->query(fn (Builder $query, array $data): Builder => match (true) {
|
||||
blank($data['value'] ?? null) => $query,
|
||||
$data['value'] === 'all_year' => $query->where(fn (Builder $query) => $query->whereNull('appearance_ids')->orWhereJsonLength('appearance_ids', 0)),
|
||||
default => $query->whereJsonContains('appearance_ids', (int) $data['value']),
|
||||
}),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
@@ -53,6 +73,22 @@ public static function configure(Table $table): Table
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
BulkAction::make('seasons')
|
||||
->label('Zeigen in …')
|
||||
->icon('heroicon-o-sun')
|
||||
->schema([
|
||||
Select::make('appearance_ids')
|
||||
->label('Zeigen in')
|
||||
->multiple()
|
||||
->options(fn (): array => Appearance::photoOptions())
|
||||
->placeholder('ganzjährig')
|
||||
->helperText('Leer = ganzjährig. Ersetzt die bisherige Zuordnung der ausgewählten Fotos.'),
|
||||
])
|
||||
->action(function (Collection $records, array $data): void {
|
||||
$records->each(fn (Photo $photo) => $photo->update(['appearance_ids' => PhotoForm::appearanceIds($data['appearance_ids'] ?? [])]));
|
||||
})
|
||||
->authorizeIndividualRecords('update')
|
||||
->deselectRecordsAfterCompletion(),
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
|
||||
@@ -2,10 +2,20 @@
|
||||
|
||||
namespace App\Filament\Resources\PortalEmails\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\PortalEmails\PortalEmailResource;
|
||||
use App\Models\Property;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListPortalEmails extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = PortalEmailResource::class;
|
||||
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->whereHas('channel', fn (Builder $channel) => $channel->where('property_id', $property->id));
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\PortalOccupations\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
@@ -9,6 +10,8 @@
|
||||
|
||||
class ManagePortalOccupations extends ManageRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = PortalOccupationResource::class;
|
||||
|
||||
public function getTabs(): array
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Filament\Actions\AssignGuestAction;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\BlockedPeriods\BlockedPeriodResource;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\Guests\GuestResource;
|
||||
@@ -32,7 +33,7 @@
|
||||
|
||||
class PortalOccupationResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = BlockedPeriod::class;
|
||||
|
||||
@@ -71,7 +72,7 @@ public static function table(Table $table): Table
|
||||
->defaultSort('starts_on')->columns([
|
||||
TextColumn::make('starts_on')->label('Anreise / Beginn')->date('d.m.Y')->sortable(),
|
||||
TextColumn::make('ends_on')->label('Abreise / Ende')->date('d.m.Y'),
|
||||
TextColumn::make('business_kind')->label('Einordnung')->state(fn (BlockedPeriod $record): string => $record->occupationKind()->getLabel())->badge(),
|
||||
TextColumn::make('business_kind')->label('Einordnung')->state(fn (BlockedPeriod $record): string => $record->is_representation ? 'Kalenderspiegelung' : $record->occupationKind()->getLabel())->badge(),
|
||||
TextColumn::make('guest_name')->label('Gast / Namensinformation')->state(fn (BlockedPeriod $record): ?string => $record->guestName())->placeholder('Zuordnung offen')
|
||||
->description(fn (BlockedPeriod $record): string => $record->guest_id ? 'Gast zugeordnet' : 'Keine bestätigte Gastzuordnung'),
|
||||
TextColumn::make('channel.name')->label('Importkanal'),
|
||||
@@ -120,7 +121,7 @@ public static function infolist(Schema $schema): Schema
|
||||
TextEntry::make('property.name')->label('Wohnung'),
|
||||
TextEntry::make('starts_on')->label('Anreise / Beginn')->date('d.m.Y'),
|
||||
TextEntry::make('ends_on')->label('Abreise / erster freier Tag')->date('d.m.Y'),
|
||||
TextEntry::make('kind')->label('Einordnung')->state(fn (BlockedPeriod $record): string => $record->occupationKind()->getLabel()),
|
||||
TextEntry::make('kind')->label('Einordnung')->state(fn (BlockedPeriod $record): string => $record->is_representation ? 'Kalenderspiegelung' : $record->occupationKind()->getLabel()),
|
||||
TextEntry::make('booking_channel')->label('Buchungskanal')->state(fn (BlockedPeriod $record): string => $record->bookingChannelLabel()),
|
||||
TextEntry::make('block_description')->label('Zweck / Grund der Sperrzeit')->state(fn (BlockedPeriod $record): ?string => $record->blockDescription())
|
||||
->visible(fn (BlockedPeriod $record): bool => $record->occupationKind() === OccupationKind::Block)->placeholder('Noch nicht angegeben'),
|
||||
@@ -131,7 +132,10 @@ public static function infolist(Schema $schema): Schema
|
||||
TextEntry::make('assignment')->label('Gastzuordnung')->state(fn (BlockedPeriod $record): string => $record->is_representation ? 'Wird an der führenden Belegung gepflegt' : ($record->guest_id ? 'Persönlich zugeordnet' : 'Noch offen; Namensfragment allein ist kein Identitätsnachweis')),
|
||||
TextEntry::make('calendar_state')->label('Kalenderstatus')->state(fn (BlockedPeriod $record): string => $record->trashed() ? 'Nicht mehr im Feed – keine Aussage über den Stornogrund' : ($record->is_representation ? 'Weitere Darstellung einer führenden Belegung' : 'Belegt den Zeitraum')),
|
||||
TextEntry::make('leading_record')->label('Führende Belegung')->state(fn (BlockedPeriod $record): string => $record->linkedBooking ? 'Buchung '.$record->linkedBooking->reference : ($record->canonical_block_id ? 'Kalenderbelegung #'.$record->canonical_block_id : 'Dieser Eintrag'))
|
||||
->url(fn (BlockedPeriod $record): ?string => $record->linked_booking_id ? BookingResource::getUrl('view', ['record' => $record->linked_booking_id]) : null),
|
||||
->url(fn (BlockedPeriod $record): ?string => $record->linked_booking_id ? BookingResource::getUrl('view', ['record' => $record->linked_booking_id]) : ($record->canonical_block_id ? static::getUrl('view', ['record' => $record->canonical_block_id]) : null)),
|
||||
TextEntry::make('representation_assignment')->label('Zuordnung der Kalenderdarstellung')
|
||||
->state(fn (BlockedPeriod $record): string => $record->representation_automatic ? 'Automatisch; wird bei jedem Abgleich erneut geprüft' : 'Persönlich bestätigt')
|
||||
->visible(fn (BlockedPeriod $record): bool => $record->is_representation),
|
||||
TextEntry::make('review_note')->label('Prüfhinweis')->placeholder('Kein zusätzlicher Prüfhinweis')->columnSpanFull(),
|
||||
]),
|
||||
Section::make('Kalenderquelle')->schema([
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
namespace App\Filament\Resources\Properties\RelationManagers;
|
||||
|
||||
use App\Enums\DiscountType;
|
||||
use App\Enums\NoticeTone;
|
||||
use App\Enums\OfferKind;
|
||||
use App\Filament\Resources\Notices\NoticeResource;
|
||||
use App\Models\Notice;
|
||||
use App\Models\SpecialOffer;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
@@ -21,9 +25,11 @@
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class SpecialOffersRelationManager extends RelationManager
|
||||
{
|
||||
@@ -218,6 +224,21 @@ public function table(Table $table): Table
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
Action::make('banner')
|
||||
->label('Als Banner zeigen')
|
||||
->icon(Heroicon::OutlinedMegaphone)
|
||||
->visible(fn (SpecialOffer $record): bool => $record->is_public && blank($record->code) && Gate::allows('create', Notice::class))
|
||||
->action(function (SpecialOffer $record) {
|
||||
$notice = Notice::query()->create([
|
||||
'site_id' => $record->property?->site_id,
|
||||
'special_offer_id' => $record->id,
|
||||
'tone' => NoticeTone::Offer,
|
||||
'priority' => 30,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return redirect(NoticeResource::getUrl('edit', ['record' => $notice]));
|
||||
}),
|
||||
ReplicateAction::make()->label('Duplizieren')->schema(fn (Schema $schema): Schema => $this->form($schema)),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Filament\Resources\Reviews\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\Reviews\ReviewResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListReviews extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = ReviewResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Enums\ReviewStatus;
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Reviews\Pages\CreateReview;
|
||||
use App\Filament\Resources\Reviews\Pages\EditReview;
|
||||
use App\Filament\Resources\Reviews\Pages\ListReviews;
|
||||
@@ -19,7 +20,7 @@
|
||||
|
||||
class ReviewResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode;
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Review::class;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\ReviewStatus;
|
||||
use App\Models\Property;
|
||||
use App\Models\Review;
|
||||
use App\Support\CurrentProperty;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -54,7 +55,7 @@ public static function configure(Schema $schema): Schema
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => Property::query()->value('id'))
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->required(),
|
||||
]),
|
||||
Section::make('Öffentliche Antwort der Gastgeber')
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos\Pages;
|
||||
|
||||
use App\Filament\Resources\Videos\VideoResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateVideo extends CreateRecord
|
||||
{
|
||||
protected static string $resource = VideoResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos\Pages;
|
||||
|
||||
use App\Filament\Resources\Videos\VideoResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditVideo extends EditRecord
|
||||
{
|
||||
protected static string $resource = VideoResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos\Pages;
|
||||
|
||||
use App\Filament\Concerns\ListsCurrentProperty;
|
||||
use App\Filament\Resources\Videos\VideoResource;
|
||||
use App\Models\Property;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class ListVideos extends ListRecords
|
||||
{
|
||||
use ListsCurrentProperty;
|
||||
|
||||
protected static string $resource = VideoResource::class;
|
||||
|
||||
/**
|
||||
* Videos of the chosen apartment and those without one (e.g. the area).
|
||||
*/
|
||||
protected function scopeToProperty(Builder $query, Property $property): Builder
|
||||
{
|
||||
return $query->where(fn (Builder $query) => $query->where('property_id', $property->id)->orWhereNull('property_id'));
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos\Schemas;
|
||||
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Property;
|
||||
use App\Models\Video;
|
||||
use App\Support\CurrentProperty;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class VideoForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(2)
|
||||
->components([
|
||||
SpatieMediaLibraryFileUpload::make('file')
|
||||
->label('Videodatei')
|
||||
->collection(Video::COLLECTION)
|
||||
->disk('public')
|
||||
->acceptedFileTypes(['video/mp4', 'application/mp4', 'video/webm'])
|
||||
->maxSize(Video::MAX_KB)
|
||||
->helperText('MP4 (H.264) oder WebM bis 100 MB. Für den Titelbereich reicht eine kurze stumme Schleife von 6–10 Sekunden und 2–4 MB – sie lädt auf jedem Handy mit.')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
SpatieMediaLibraryFileUpload::make('poster')
|
||||
->label('Standbild')
|
||||
->collection(Video::POSTER)
|
||||
->disk('public')
|
||||
->image()
|
||||
->maxSize(25 * 1024)
|
||||
->helperText('Wird gezeigt, bis das Video läuft, und statt des Videos, wenn Besucher „Bewegung reduzieren“ eingestellt haben. Am besten ein Bild aus dem Video.')
|
||||
->required()
|
||||
->columnSpanFull(),
|
||||
TextInput::make('title')
|
||||
->label('Titel')
|
||||
->helperText('Für Sie zur Auswahl in den Bausteinen und für Screenreader („Video: …“).')
|
||||
->required()
|
||||
->maxLength(160),
|
||||
Select::make('property_id')
|
||||
->label('Wohnung')
|
||||
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
|
||||
->default(fn (): ?int => app(CurrentProperty::class)->id())
|
||||
->placeholder('– keine (z. B. Umgebung) –')
|
||||
->live(),
|
||||
Section::make('Kapitel')
|
||||
->description('Für den Rundgang: Besucher springen per Knopf zu einem Raum. Ist ein Raum aus dem Grundriss gewählt, bietet der Grundriss bei diesem Raum „Im Video ansehen“ an.')
|
||||
->collapsible()
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Repeater::make('chapters')
|
||||
->hiddenLabel()
|
||||
->addActionLabel('Kapitel hinzufügen')
|
||||
->columns(3)
|
||||
->defaultItems(0)
|
||||
->reorderable(false)
|
||||
->itemLabel(fn (array $state): ?string => trim(($state['at'] ?? '').' '.($state['label'] ?? '')) ?: null)
|
||||
->schema([
|
||||
TextInput::make('at')
|
||||
->label('Ab (Min:Sek)')
|
||||
->placeholder('0:16')
|
||||
->required()
|
||||
->rules([fn (): Closure => function (string $attribute, mixed $value, Closure $fail): void {
|
||||
if (Video::seconds($value) === null) {
|
||||
$fail('Bitte als Minuten:Sekunden angeben, z. B. 0:16 oder 1:05.');
|
||||
}
|
||||
}]),
|
||||
TextInput::make('label')
|
||||
->label('Bezeichnung')
|
||||
->placeholder('Wohnzimmer')
|
||||
->required()
|
||||
->maxLength(60),
|
||||
Select::make('room')
|
||||
->label('Raum im Grundriss')
|
||||
->options(fn (Get $get): array => self::roomOptions($get('../../property_id')))
|
||||
->placeholder('– keiner –'),
|
||||
]),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Names of the visible floor plan rooms of the apartment (name => name).
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function roomOptions(mixed $propertyId): array
|
||||
{
|
||||
$plan = filled($propertyId) ? FloorPlan::query()->where('property_id', $propertyId)->first() : null;
|
||||
|
||||
return $plan?->visibleRooms()->pluck('name', 'name')->all() ?? [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos\Tables;
|
||||
|
||||
use App\Models\Video;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\SpatieMediaLibraryImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class VideosTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('title')
|
||||
->emptyStateHeading('Noch keine Videos')
|
||||
->emptyStateDescription('Laden Sie ein Video hoch und wählen Sie es danach im Titelbereich oder im Baustein „Rundgang (Video)“ aus.')
|
||||
->columns([
|
||||
SpatieMediaLibraryImageColumn::make('poster')
|
||||
->label('')
|
||||
->collection(Video::POSTER)
|
||||
->conversion('poster')
|
||||
->imageHeight(64),
|
||||
TextColumn::make('title')->label('Titel')->searchable()->weight('medium'),
|
||||
TextColumn::make('property.name')->label('Wohnung')->placeholder('–'),
|
||||
TextColumn::make('chapters')
|
||||
->label('Kapitel')
|
||||
->state(fn (Video $record): string => (string) count($record->chapterList())),
|
||||
TextColumn::make('size')
|
||||
->label('Größe')
|
||||
->state(fn (Video $record): ?string => $record->getFirstMedia(Video::COLLECTION)?->human_readable_size),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Videos;
|
||||
|
||||
use App\Filament\Concerns\FollowsAdminMode;
|
||||
use App\Filament\Concerns\SelectsRecordProperty;
|
||||
use App\Filament\Resources\Videos\Pages\CreateVideo;
|
||||
use App\Filament\Resources\Videos\Pages\EditVideo;
|
||||
use App\Filament\Resources\Videos\Pages\ListVideos;
|
||||
use App\Filament\Resources\Videos\Schemas\VideoForm;
|
||||
use App\Filament\Resources\Videos\Tables\VideosTable;
|
||||
use App\Models\Video;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
/**
|
||||
* Website videos: chosen in the hero section (silent loop) and in the tour section (with chapters).
|
||||
*/
|
||||
class VideoResource extends Resource
|
||||
{
|
||||
use FollowsAdminMode, SelectsRecordProperty;
|
||||
|
||||
protected static ?string $model = Video::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedFilm;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Webseite';
|
||||
|
||||
protected static ?string $modelLabel = 'Video';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Videos';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return VideoForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return VideosTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListVideos::route('/'),
|
||||
'create' => CreateVideo::route('/create'),
|
||||
'edit' => EditVideo::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -43,8 +43,8 @@ public function show(string $slug): View
|
||||
'sections' => $this->sections->render($this->theme(), $page->sections),
|
||||
'title' => $page->isHome() ? null : ($page->seo_title ?: $page->title),
|
||||
'description' => $page->seo_description ?: ($page->isHome() ? Content::get('seo.home.description') : null),
|
||||
'ogImage' => $this->theme()->heroPhoto()?->url('lg') ?: null,
|
||||
'structuredData' => $page->isHome() ? $this->structuredData() : null,
|
||||
'ogImage' => $this->theme()->sharePhoto($page->sections ?? [])?->url('lg') ?: null,
|
||||
'structuredData' => $page->isHome() ? $this->structuredData($page) : null,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public function robots(): Response
|
||||
*
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
private function structuredData(): ?array
|
||||
private function structuredData(Page $page): ?array
|
||||
{
|
||||
$property = $this->theme()->property();
|
||||
if ($property === null) {
|
||||
@@ -89,7 +89,7 @@ private function structuredData(): ?array
|
||||
'@type' => 'VacationRental',
|
||||
'name' => $property->name,
|
||||
'url' => route('home'),
|
||||
'image' => $this->theme()->heroPhoto()?->url('lg') ?: null,
|
||||
'image' => $this->theme()->sharePhoto($page->sections ?? [])?->url('lg') ?: null,
|
||||
'address' => ['@type' => 'PostalAddress', 'streetAddress' => str($property->address)->before(',')->trim()->toString(), 'addressLocality' => 'Kühlungsborn', 'postalCode' => '18225', 'addressCountry' => 'DE'],
|
||||
'containsPlace' => ['@type' => 'Accommodation', 'floorSize' => ['@type' => 'QuantitativeValue', 'value' => $property->size_sqm, 'unitCode' => 'MTK'], 'occupancy' => ['@type' => 'QuantitativeValue', 'maxValue' => $property->max_guests]],
|
||||
'telephone' => config('fewo.owner.phone'),
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Filament\Resources\Properties\PropertyResource;
|
||||
use App\Models\Property;
|
||||
use App\Support\CurrentProperty;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Apartment switcher in the admin menu: remembers the choice and returns to the page the admin came from.
|
||||
* A record page of the previous apartment is left for its list; the settings of the previous apartment
|
||||
* lead to the settings of the chosen one.
|
||||
*/
|
||||
class SwitchPropertyController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, CurrentProperty $current): RedirectResponse
|
||||
{
|
||||
$property = Property::query()->findOrFail($request->integer('property'));
|
||||
$current->select($property);
|
||||
|
||||
return redirect()->to($this->target($request->input('return', url()->previous()), $property));
|
||||
}
|
||||
|
||||
private function target(string $previous, Property $property): string
|
||||
{
|
||||
$fallback = route('filament.admin.pages.dashboard');
|
||||
if (! Str::startsWith($previous, url('/admin'))) {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
try {
|
||||
$route = Route::getRoutes()->match(Request::create($previous));
|
||||
} catch (HttpException) {
|
||||
return $fallback;
|
||||
}
|
||||
|
||||
$name = (string) $route->getName();
|
||||
if (Str::startsWith($name, 'filament.admin.resources.properties.')) {
|
||||
return PropertyResource::getUrl('edit', ['record' => $property]);
|
||||
}
|
||||
|
||||
if (Str::endsWith($name, ['.edit', '.view'])) {
|
||||
$index = Str::beforeLast($name, '.').'.index';
|
||||
|
||||
return Route::has($index) ? route($index) : $fallback;
|
||||
}
|
||||
|
||||
// A page's own apartment parameter would undo the switch.
|
||||
$query = [];
|
||||
parse_str((string) parse_url($previous, PHP_URL_QUERY), $query);
|
||||
unset($query['wohnung']);
|
||||
|
||||
return strtok($previous, '?').($query !== [] ? '?'.http_build_query($query) : '');
|
||||
}
|
||||
}
|
||||
@@ -10,19 +10,23 @@
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Reports overlaps between a newly imported portal occupation and occupations from elsewhere.
|
||||
* Reports overlaps between an imported portal occupation and occupations from elsewhere: new ones and
|
||||
* reminders about ones that are still open.
|
||||
*/
|
||||
class ChannelConflict extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/** @param list<string> $conflicts */
|
||||
public function __construct(public Channel $channel, public array $conflicts) {}
|
||||
/**
|
||||
* @param list<string> $conflicts reported for the first time
|
||||
* @param list<string> $reminders reported before, still unread and still detected
|
||||
*/
|
||||
public function __construct(public Channel $channel, public array $conflicts, public array $reminders = []) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Achtung: mögliche Doppelbuchung über '.$this->channel->name,
|
||||
subject: ($this->conflicts === [] ? 'Erinnerung' : 'Achtung').': mögliche Doppelbuchung über '.$this->channel->name,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Enums\DigestSection;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* The landlord's daily or weekly summary of open points and news (SendDigests, DigestReport).
|
||||
*/
|
||||
class Digest extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @param list<array{section: DigestSection, title: string, items: list<string>, more: int, url: string, link: string}> $sections
|
||||
*/
|
||||
public function __construct(public bool $weekly, public array $sections) {}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$title = $this->weekly ? 'Wochenübersicht KW '.now()->isoWeek() : 'Tagesübersicht '.now()->format('d.m.Y');
|
||||
$count = array_sum(array_map(fn (array $section): int => count($section['items']) + $section['more'], $this->sections));
|
||||
|
||||
return new Envelope(
|
||||
subject: $title.($count === 0 ? ': nichts Neues' : ": {$count} ".($count === 1 ? 'Punkt' : 'Punkte')),
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
markdown: 'mail.digest',
|
||||
);
|
||||
}
|
||||
}
|
||||
+41
-10
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Tenancy\TenantContext;
|
||||
use Carbon\CarbonInterface;
|
||||
use Database\Factories\AppearanceFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
@@ -11,12 +12,12 @@
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* A seasonal look of a site (e.g. summer, winter, Christmas, New Year's Eve): colour tokens, hero photo,
|
||||
* photos per section, texts and banner change – the page structure does not (sections may be limited to
|
||||
* A seasonal look of a site (e.g. summer, winter, Christmas, New Year's Eve): colour tokens and texts change,
|
||||
* photos and banners made for it (appearance_ids) are shown – the page structure does not (sections may be limited to
|
||||
* appearances, see SectionRegistry). Offers are advertised by their own rules (OfferShowcase). The period recurs every year ("MM-DD" to "MM-DD",
|
||||
* inclusive; a period may run over the turn of the year). The default appearance applies when none matches.
|
||||
*/
|
||||
#[Fillable(['site_id', 'name', 'starts_md', 'ends_md', 'priority', 'is_default', 'is_active', 'tokens', 'overrides', 'hero_photo_id', 'section_photos'])]
|
||||
#[Fillable(['site_id', 'name', 'starts_md', 'ends_md', 'priority', 'is_default', 'is_active', 'tokens', 'overrides'])]
|
||||
class Appearance extends Model
|
||||
{
|
||||
/** @use HasFactory<AppearanceFactory> */
|
||||
@@ -26,9 +27,6 @@ class Appearance extends Model
|
||||
* Texts an appearance can replace, with their admin labels. Sections read them through Theme::text().
|
||||
*/
|
||||
public const OVERRIDABLE = [
|
||||
'banner.text' => 'Banner: Text',
|
||||
'banner.link_label' => 'Banner: Link-Text',
|
||||
'banner.link_url' => 'Banner: Link-Ziel',
|
||||
'hero.eyebrow' => 'Titelbereich: kleine Überschrift',
|
||||
'hero.title' => 'Titelbereich: Überschrift',
|
||||
'hero.text' => 'Titelbereich: Text',
|
||||
@@ -48,7 +46,6 @@ protected function casts(): array
|
||||
'is_active' => 'boolean',
|
||||
'tokens' => 'array',
|
||||
'overrides' => 'array',
|
||||
'section_photos' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -61,11 +58,45 @@ public function site(): BelongsTo
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Photo, $this>
|
||||
* Names by id of the landlord's appearances, loaded once per request and landlord.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function heroPhoto(): BelongsTo
|
||||
public static function names(): array
|
||||
{
|
||||
return $this->belongsTo(Photo::class, 'hero_photo_id');
|
||||
$tenantId = app(TenantContext::class)->id();
|
||||
|
||||
// once() keys its cache by the variables the closure uses, so each landlord gets its own entry.
|
||||
return once(fn (): array => self::query()->when($tenantId, fn ($query) => $query->where('tenant_id', $tenantId))->pluck('name', 'id')->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Choices for "Zeigen in" at the photos, e.g. "Winter · 01.11.–31.03."; with several websites prefixed by the website.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public static function photoOptions(): array
|
||||
{
|
||||
$appearances = self::query()->with('site')->orderByDesc('is_default')->orderBy('starts_md')->orderBy('name')->get();
|
||||
$severalSites = $appearances->pluck('site_id')->unique()->count() > 1;
|
||||
|
||||
return $appearances->mapWithKeys(fn (Appearance $appearance): array => [
|
||||
$appearance->id => ($severalSites ? $appearance->site?->name.': ' : '').$appearance->periodLabel(),
|
||||
])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* "Winter · 01.11.–31.03.", "Standard · wenn kein Zeitraum passt".
|
||||
*/
|
||||
public function periodLabel(): string
|
||||
{
|
||||
if ($this->starts_md === null || $this->ends_md === null) {
|
||||
return $this->name.($this->is_default ? ' · wenn kein Zeitraum passt' : '');
|
||||
}
|
||||
|
||||
$day = fn (string $monthDay): string => substr($monthDay, 3, 2).'.'.substr($monthDay, 0, 2).'.';
|
||||
|
||||
return $this->name.' · '.$day($this->starts_md).'–'.$day($this->ends_md);
|
||||
}
|
||||
|
||||
public function covers(CarbonInterface $date): bool
|
||||
|
||||
@@ -32,7 +32,7 @@ class BlockedPeriod extends Model
|
||||
/** @use HasFactory<BlockedPeriodFactory> */
|
||||
use BelongsToTenant, HasChannelProvenance, HasFactory, SoftDeletes;
|
||||
|
||||
protected $attributes = ['is_representation' => false, 'export_approved' => true];
|
||||
protected $attributes = ['is_representation' => false, 'representation_automatic' => false, 'export_approved' => true];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -50,6 +50,7 @@ protected function casts(): array
|
||||
'needs_review' => 'boolean',
|
||||
'missing_imports' => 'integer',
|
||||
'is_representation' => 'boolean',
|
||||
'representation_automatic' => 'boolean',
|
||||
'export_approved' => 'boolean',
|
||||
'reviewed_at' => 'immutable_datetime',
|
||||
'ical_properties' => 'encrypted:array',
|
||||
@@ -119,6 +120,10 @@ public function guestName(): ?string
|
||||
|
||||
public function bookingChannelLabel(): string
|
||||
{
|
||||
if ($this->is_representation) {
|
||||
return $this->canonicalBlock?->bookingChannelLabel() ?? $this->linkedBooking?->bookingChannelLabel() ?? 'Führende Belegung nicht verfügbar';
|
||||
}
|
||||
|
||||
return $this->is_private ? 'Privat' : ($this->originChannel?->name ?? $this->channel?->name ?? ($this->source === 'manual' ? 'Eigene Sperre' : 'Ursprung unbekannt'));
|
||||
}
|
||||
|
||||
@@ -170,8 +175,9 @@ protected function unclear(Builder $query): Builder
|
||||
{
|
||||
return $query->whereIn('source', ['channel', 'email'])->where(fn (Builder $query) => $query
|
||||
->where('needs_review', true)
|
||||
->orWhere('occupation_kind', OccupationKind::Unknown)
|
||||
->orWhere(fn (Builder $query) => $query->whereNull('occupation_kind')->where(fn (Builder $query) => $query->whereNull('ical_event_type')->orWhere('ical_event_type', '!=', 'portal_reservation'))));
|
||||
->orWhere(fn (Builder $query) => $query->where('is_representation', false)->where(fn (Builder $query) => $query
|
||||
->where('occupation_kind', OccupationKind::Unknown)
|
||||
->orWhere(fn (Builder $query) => $query->whereNull('occupation_kind')->where(fn (Builder $query) => $query->whereNull('ical_event_type')->orWhere('ical_event_type', '!=', 'portal_reservation'))))));
|
||||
}
|
||||
|
||||
/** @param Builder<BlockedPeriod> $query
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use App\Models\Appearance;
|
||||
|
||||
/**
|
||||
* For models with an "appearance_ids" list (photos, banners): none = all year, otherwise only while one of
|
||||
* these appearances (summer, winter, Christmas …) is in effect.
|
||||
*/
|
||||
trait BelongsToAppearances
|
||||
{
|
||||
/**
|
||||
* Appearance ids as integers (the form may deliver strings).
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function appearanceIds(): array
|
||||
{
|
||||
return array_values(array_unique(array_map('intval', array_filter((array) $this->appearance_ids))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the record may be shown while this appearance is in effect: all-year ones always, seasonal ones in their seasons.
|
||||
*/
|
||||
public function fitsSeason(?Appearance $appearance): bool
|
||||
{
|
||||
return $this->appearanceIds() === [] || $this->isMadeFor($appearance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the record was chosen for this appearance.
|
||||
*/
|
||||
public function isMadeFor(?Appearance $appearance): bool
|
||||
{
|
||||
return $appearance !== null && in_array($appearance->id, $this->appearanceIds(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Names of the appearances the record is made for (empty = all year).
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function appearanceNames(): array
|
||||
{
|
||||
return array_values(array_intersect_key(Appearance::names(), array_flip($this->appearanceIds())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\InboxMessageFactory;
|
||||
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 message in the admin inbox ("Postfach"). The fingerprint identifies the finding, so the same
|
||||
* finding is posted – and e-mailed – only once per landlord (App\Support\Inbox).
|
||||
*/
|
||||
#[Fillable(['property_id', 'channel_id', 'kind', 'fingerprint', 'subject', 'body', 'action_url', 'notified_at', 'last_seen_at', 'read_at'])]
|
||||
class InboxMessage extends Model
|
||||
{
|
||||
/** @use HasFactory<InboxMessageFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'kind' => InboxMessageKind::class,
|
||||
'notified_at' => 'immutable_datetime',
|
||||
'last_seen_at' => 'immutable_datetime',
|
||||
'read_at' => 'immutable_datetime',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Property, $this>
|
||||
*/
|
||||
public function property(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Property::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Channel, $this>
|
||||
*/
|
||||
public function channel(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Channel::class);
|
||||
}
|
||||
|
||||
public function isRead(): bool
|
||||
{
|
||||
return $this->read_at !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<InboxMessage> $query
|
||||
* @return Builder<InboxMessage>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function unread(Builder $query): Builder
|
||||
{
|
||||
return $query->whereNull('read_at');
|
||||
}
|
||||
}
|
||||
+25
-3
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\NoticeTone;
|
||||
use App\Models\Concerns\BelongsToAppearances;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\NoticeFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
@@ -10,15 +11,18 @@
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* A banner shown on the website, optionally limited to a date range.
|
||||
* A banner at the top of the website: for one website or all, optionally only in some appearances (seasons)
|
||||
* and within a date range. It may advertise a special offer – then text, dates and link come from the offer
|
||||
* and the banner only shows while the website advertises that offer. The highest priority wins (BannerResolver).
|
||||
*/
|
||||
#[Fillable(['text', 'tone', 'link_url', 'link_label', 'starts_on', 'ends_on', 'is_active'])]
|
||||
#[Fillable(['site_id', 'special_offer_id', 'appearance_ids', 'priority', 'text', 'tone', 'link_url', 'link_label', 'starts_on', 'ends_on', 'is_active'])]
|
||||
class Notice extends Model
|
||||
{
|
||||
/** @use HasFactory<NoticeFactory> */
|
||||
use BelongsToTenant, HasFactory;
|
||||
use BelongsToAppearances, BelongsToTenant, HasFactory;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -29,12 +33,30 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'tone' => NoticeTone::class,
|
||||
'appearance_ids' => 'array',
|
||||
'priority' => 'integer',
|
||||
'starts_on' => 'immutable_date',
|
||||
'ends_on' => 'immutable_date',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Site, $this>
|
||||
*/
|
||||
public function site(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<SpecialOffer, $this>
|
||||
*/
|
||||
public function specialOffer(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SpecialOffer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Active notices whose date range includes today.
|
||||
*
|
||||
|
||||
+49
-2
@@ -3,11 +3,13 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Models\Concerns\BelongsToAppearances;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
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\Collection as EloquentCollection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -18,12 +20,14 @@
|
||||
|
||||
/**
|
||||
* A website photo. The uploaded original is kept; web sizes are generated as WebP on upload.
|
||||
* A photo may belong to appearances (seasons such as summer, winter, Christmas): then it is only shown while
|
||||
* one of them is in effect, and ahead of the all-year photos. Without appearances it is shown all year.
|
||||
*/
|
||||
#[Fillable(['property_id', 'category', 'alt_text', 'caption', 'is_published', 'sort_order'])]
|
||||
#[Fillable(['property_id', 'category', 'appearance_ids', 'alt_text', 'caption', 'is_published', 'sort_order'])]
|
||||
class Photo extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<PhotoFactory> */
|
||||
use BelongsToTenant, HasFactory, InteractsWithMedia;
|
||||
use BelongsToAppearances, BelongsToTenant, HasFactory, InteractsWithMedia;
|
||||
|
||||
public const COLLECTION = 'image';
|
||||
|
||||
@@ -39,6 +43,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'category' => PhotoCategory::class,
|
||||
'appearance_ids' => 'array',
|
||||
'is_published' => 'boolean',
|
||||
];
|
||||
}
|
||||
@@ -81,6 +86,48 @@ protected function published(Builder $query): Builder
|
||||
return $query->where('is_published', true)->orderBy('sort_order');
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos a gallery or an automatic choice may show – floor plans and drawings only appear where chosen.
|
||||
*
|
||||
* @param Builder<Photo> $query
|
||||
* @return Builder<Photo>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function forGalleries(Builder $query): Builder
|
||||
{
|
||||
return $query->whereIn('category', PhotoCategory::forGalleries());
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos of the apartment and those without an apartment (e.g. the area); without an apartment all photos.
|
||||
*
|
||||
* @param Builder<Photo> $query
|
||||
* @return Builder<Photo>
|
||||
*/
|
||||
#[Scope]
|
||||
protected function forProperty(Builder $query, ?Property $property): Builder
|
||||
{
|
||||
return $property === null
|
||||
? $query
|
||||
: $query->where(fn (Builder $query) => $query->where('property_id', $property->id)->orWhereNull('property_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos picked automatically: published, of the apartment and those without one, never plans, fitting the
|
||||
* season – photos made for the appearance in effect first, then the all-year photos in their order.
|
||||
*
|
||||
* @return EloquentCollection<int, Photo>
|
||||
*/
|
||||
public static function automatic(?Property $property, ?Appearance $appearance, ?PhotoCategory $category = null): EloquentCollection
|
||||
{
|
||||
return self::query()->published()->forGalleries()->forProperty($property)->with('media')
|
||||
->when($category, fn (Builder $query) => $query->where('category', $category))
|
||||
->get()
|
||||
->filter(fn (Photo $photo): bool => $photo->fitsSeason($appearance))
|
||||
->sortBy(fn (Photo $photo): int => $photo->isMadeFor($appearance) ? 0 : 1)
|
||||
->values();
|
||||
}
|
||||
|
||||
public function url(string $size = 'md'): string
|
||||
{
|
||||
return $this->getFirstMediaUrl(self::COLLECTION, $size);
|
||||
|
||||
@@ -26,12 +26,24 @@
|
||||
'retention_portal_email_excerpt_days', 'retention_attribution_months',
|
||||
'spam_min_seconds', 'spam_per_ip_per_hour', 'spam_per_email_per_day', 'spam_open_requests_per_email', 'spam_max_links',
|
||||
'channel_stale_after_minutes', 'channel_task_reminder_after_minutes',
|
||||
'reminder_interval_days', 'digest_daily', 'digest_weekly', 'digest_weekday', 'digest_hour', 'digest_sections',
|
||||
'digest_when_empty', 'digest_daily_sent_on', 'digest_weekly_sent_on',
|
||||
])]
|
||||
class Tenant extends Model
|
||||
{
|
||||
/** @use HasFactory<TenantFactory> */
|
||||
use HasFactory;
|
||||
|
||||
/** Reminder and summary defaults: repeat nothing, a daily summary from 7 a.m., the weekly one on Mondays. */
|
||||
protected $attributes = [
|
||||
'reminder_interval_days' => 0,
|
||||
'digest_daily' => true,
|
||||
'digest_weekly' => false,
|
||||
'digest_weekday' => 1,
|
||||
'digest_hour' => 7,
|
||||
'digest_when_empty' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The landlord the existing single-website data belongs to.
|
||||
*/
|
||||
@@ -56,6 +68,15 @@ protected function casts(): array
|
||||
'bank_name' => 'encrypted',
|
||||
'tax_note' => 'encrypted',
|
||||
'mailbox_password' => 'encrypted',
|
||||
'reminder_interval_days' => 'integer',
|
||||
'digest_daily' => 'boolean',
|
||||
'digest_weekly' => 'boolean',
|
||||
'digest_weekday' => 'integer',
|
||||
'digest_hour' => 'integer',
|
||||
'digest_sections' => 'array',
|
||||
'digest_when_empty' => 'boolean',
|
||||
'digest_daily_sent_on' => 'immutable_date',
|
||||
'digest_weekly_sent_on' => 'immutable_date',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Database\Factories\VideoFactory;
|
||||
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
||||
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 video: a short silent loop for the hero section or a tour with chapters (TourSection).
|
||||
* Chapters link a moment to a floor plan room by its name, so the floor plan can jump into the video.
|
||||
*
|
||||
* @property list<array{at?: string, label?: string, room?: string|null}>|null $chapters
|
||||
*/
|
||||
#[Fillable(['property_id', 'title', 'chapters'])]
|
||||
class Video extends Model implements HasMedia
|
||||
{
|
||||
/** @use HasFactory<VideoFactory> */
|
||||
use BelongsToTenant, HasFactory, InteractsWithMedia;
|
||||
|
||||
public const COLLECTION = 'video';
|
||||
|
||||
public const POSTER = 'poster';
|
||||
|
||||
/** Largest accepted video file in KB (Strato allows uploads up to 128 MB). */
|
||||
public const MAX_KB = 100 * 1024;
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'chapters' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection(self::COLLECTION)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['video/mp4', 'application/mp4', 'video/webm']);
|
||||
|
||||
$this->addMediaCollection(self::POSTER)
|
||||
->useDisk('public')
|
||||
->singleFile()
|
||||
->acceptsMimeTypes(['image/jpeg', 'image/png', 'image/webp']);
|
||||
}
|
||||
|
||||
public function registerMediaConversions(?Media $media = null): void
|
||||
{
|
||||
$this->addMediaConversion('poster')
|
||||
->fit(Fit::Max, 1920, 1920)
|
||||
->format('webp')
|
||||
->quality(80)
|
||||
->performOnCollections(self::POSTER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Property, $this>
|
||||
*/
|
||||
public function property(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Property::class);
|
||||
}
|
||||
|
||||
public function url(): ?string
|
||||
{
|
||||
return $this->getFirstMediaUrl(self::COLLECTION) ?: null;
|
||||
}
|
||||
|
||||
public function mimeType(): string
|
||||
{
|
||||
return $this->getFirstMedia(self::COLLECTION)?->mime_type ?? 'video/mp4';
|
||||
}
|
||||
|
||||
public function posterUrl(): ?string
|
||||
{
|
||||
return $this->getFirstMediaUrl(self::POSTER, 'poster') ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chapters in time order with the start in seconds; entries without a valid time or label are left out.
|
||||
*
|
||||
* @return list<array{seconds: int, time: string, label: string, room: string|null}>
|
||||
*/
|
||||
public function chapterList(): array
|
||||
{
|
||||
$chapters = [];
|
||||
foreach ($this->chapters ?? [] as $chapter) {
|
||||
$seconds = self::seconds($chapter['at'] ?? null);
|
||||
if ($seconds === null || blank($chapter['label'] ?? null)) {
|
||||
continue;
|
||||
}
|
||||
$chapters[] = [
|
||||
'seconds' => $seconds,
|
||||
'time' => sprintf('%d:%02d', intdiv($seconds, 60), $seconds % 60),
|
||||
'label' => (string) $chapter['label'],
|
||||
'room' => filled($chapter['room'] ?? null) ? (string) $chapter['room'] : null,
|
||||
];
|
||||
}
|
||||
|
||||
usort($chapters, fn (array $a, array $b): int => $a['seconds'] <=> $b['seconds']);
|
||||
|
||||
return $chapters;
|
||||
}
|
||||
|
||||
/**
|
||||
* The chapter showing a floor plan room (matched by name), if any.
|
||||
*
|
||||
* @return array{seconds: int, time: string, label: string, room: string|null}|null
|
||||
*/
|
||||
public function chapterForRoom(string $room): ?array
|
||||
{
|
||||
foreach ($this->chapterList() as $chapter) {
|
||||
if ($chapter['room'] !== null && mb_strtolower($chapter['room']) === mb_strtolower($room)) {
|
||||
return $chapter;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* "1:05" or "65" → 65; anything else → null.
|
||||
*/
|
||||
public static function seconds(mixed $value): ?int
|
||||
{
|
||||
$value = trim((string) $value);
|
||||
if (preg_match('/^(\d{1,3}):([0-5]\d)$/', $value, $match)) {
|
||||
return (int) $match[1] * 60 + (int) $match[2];
|
||||
}
|
||||
|
||||
return preg_match('/^\d{1,4}$/', $value) ? (int) $value : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Permission;
|
||||
|
||||
class InboxMessagePolicy extends RolePolicy
|
||||
{
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return Permission::Bookings;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Enums\Permission;
|
||||
|
||||
class VideoPolicy extends RolePolicy
|
||||
{
|
||||
protected function permission(): Permission
|
||||
{
|
||||
return Permission::Content;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Providers\Filament;
|
||||
|
||||
use App\Enums\AdminMode;
|
||||
use App\Http\Controllers\SwitchPropertyController;
|
||||
use App\Http\Middleware\ResolveTheme;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Action;
|
||||
@@ -25,6 +26,7 @@
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestForgery;
|
||||
use Illuminate\Routing\Middleware\SubstituteBindings;
|
||||
use Illuminate\Session\Middleware\StartSession;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\View\Middleware\ShareErrorsFromSession;
|
||||
|
||||
class AdminPanelProvider extends PanelProvider
|
||||
@@ -68,6 +70,11 @@ public function panel(Panel $panel): Panel
|
||||
->brandName('FeWo Stommer · Verwaltung')
|
||||
// As long as the site is not switched live, every page shows where the e-mails go.
|
||||
->renderHook(PanelsRenderHook::BODY_START, fn (): View => view('filament.test-mode-banner'))
|
||||
// Apartment switcher at the top of the menu; lists and new records follow the chosen apartment.
|
||||
->renderHook(PanelsRenderHook::SIDEBAR_NAV_START, fn (): View => view('filament.property-switcher'))
|
||||
->authenticatedRoutes(function (): void {
|
||||
Route::post('wohnung-wechseln', SwitchPropertyController::class)->name('switch-property');
|
||||
})
|
||||
->navigationGroups(['Vermietung', 'Webseite', 'System'])
|
||||
->colors([
|
||||
'primary' => Color::Sky,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Models\Property;
|
||||
use App\Tenancy\TenantContext;
|
||||
|
||||
/**
|
||||
* The apartment the admin is working on (switcher at the top of the admin menu). Lists, new records and the
|
||||
* pages for one apartment follow it. Stored in the session per landlord; without a valid choice the first
|
||||
* active apartment applies, then any apartment.
|
||||
*/
|
||||
class CurrentProperty
|
||||
{
|
||||
private const SESSION_KEY = 'admin.current_property';
|
||||
|
||||
public function get(): ?Property
|
||||
{
|
||||
$chosen = $this->chosenId();
|
||||
$property = $chosen !== null ? Property::query()->find($chosen) : null;
|
||||
|
||||
return $property
|
||||
?? Property::query()->where('is_active', true)->orderBy('id')->first()
|
||||
?? Property::query()->orderBy('id')->first();
|
||||
}
|
||||
|
||||
public function id(): ?int
|
||||
{
|
||||
return $this->get()?->id;
|
||||
}
|
||||
|
||||
public function select(Property $property): void
|
||||
{
|
||||
if (app()->bound('session')) {
|
||||
session()->put(self::SESSION_KEY.'.'.$this->tenantKey(), $property->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An apartment named in a page URL (old links, e-mails) becomes the choice; another landlord's apartment is not found.
|
||||
*/
|
||||
public function followUrl(?int $propertyId): ?int
|
||||
{
|
||||
if ($propertyId === null) {
|
||||
return $this->id();
|
||||
}
|
||||
|
||||
$this->select(Property::query()->findOrFail($propertyId));
|
||||
|
||||
return $propertyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the landlord has more than one apartment to choose from.
|
||||
*/
|
||||
public function hasChoice(): bool
|
||||
{
|
||||
return Property::query()->count() > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function options(): array
|
||||
{
|
||||
return Property::query()->orderBy('name')->get()
|
||||
->mapWithKeys(fn (Property $property): array => [$property->id => $property->is_active ? $property->name : $property->name.' (inaktiv)'])
|
||||
->all();
|
||||
}
|
||||
|
||||
private function chosenId(): ?int
|
||||
{
|
||||
if (! app()->bound('session')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = session()->get(self::SESSION_KEY.'.'.$this->tenantKey());
|
||||
|
||||
return is_numeric($id) ? (int) $id : null;
|
||||
}
|
||||
|
||||
private function tenantKey(): string
|
||||
{
|
||||
return (string) (app(TenantContext::class)->id() ?? 'none');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Enums\BookingStatus;
|
||||
use App\Enums\DigestSection;
|
||||
use App\Enums\PortalEmailStatus;
|
||||
use App\Enums\ReviewStatus;
|
||||
use App\Filament\Pages\OccupancyCalendar;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Filament\Resources\ChannelTasks\ChannelTaskResource;
|
||||
use App\Filament\Resources\InboxMessages\InboxMessageResource;
|
||||
use App\Filament\Resources\PortalOccupations\PortalOccupationResource;
|
||||
use App\Filament\Resources\Reviews\ReviewResource;
|
||||
use App\Models\BlockedPeriod;
|
||||
use App\Models\Booking;
|
||||
use App\Models\Channel;
|
||||
use App\Models\ChannelTask;
|
||||
use App\Models\InboxMessage;
|
||||
use App\Models\PortalEmail;
|
||||
use App\Models\Property;
|
||||
use App\Models\Review;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Collects what the landlord should know for the daily or weekly summary (SendDigests). Each section lists
|
||||
* at most MAX_ITEMS lines and says how many more there are; empty sections are left out. Lines are Markdown
|
||||
* with HTML-escaped data, so the mail renders them unescaped.
|
||||
*/
|
||||
class DigestReport
|
||||
{
|
||||
public const MAX_ITEMS = 10;
|
||||
|
||||
private bool $namesProperty = false;
|
||||
|
||||
/**
|
||||
* @param list<DigestSection> $sections
|
||||
* @return list<array{section: DigestSection, title: string, items: list<string>, more: int, url: string, link: string}>
|
||||
*/
|
||||
public function build(array $sections, bool $weekly, CarbonImmutable $since): array
|
||||
{
|
||||
$this->namesProperty = Property::query()->count() > 1;
|
||||
$report = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
[$title, $lines, $url, $link] = match ($section) {
|
||||
DigestSection::Inbox => ['Postfach: ungelesene Meldungen', $this->inbox(), InboxMessageResource::getUrl('index'), 'Postfach öffnen'],
|
||||
DigestSection::Requests => ['Offene Anfragen und Angebote', $this->requests(), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::News => ['Neu seit '.$since->format('d.m. H:i').' Uhr', $this->news($since), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::Stays => [$weekly ? 'An- und Abreisen der nächsten 7 Tage' : 'An- und Abreisen heute und morgen', $this->stays($weekly ? 7 : 2), OccupancyCalendar::getUrl(), 'Belegungsplan öffnen'],
|
||||
DigestSection::Payments => ['Überfällige Zahlungen', $this->payments(), BookingResource::getUrl('index'), 'Buchungen öffnen'],
|
||||
DigestSection::Portals => ['Portale: Aufgaben und Klärungsfälle', $this->portals(), ChannelTaskResource::getUrl('index'), 'Portal-Aufgaben öffnen'],
|
||||
DigestSection::Reviews => ['Bewertungen zur Freigabe', $this->reviews(), ReviewResource::getUrl('index'), 'Bewertungen öffnen'],
|
||||
};
|
||||
|
||||
if ($lines->isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$report[] = [
|
||||
'section' => $section,
|
||||
'title' => $title,
|
||||
'items' => $lines->take(self::MAX_ITEMS)->values()->all(),
|
||||
'more' => max(0, $lines->count() - self::MAX_ITEMS),
|
||||
'url' => $url,
|
||||
'link' => $link,
|
||||
];
|
||||
}
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function inbox(): Collection
|
||||
{
|
||||
return InboxMessage::query()->unread()->latest()->get()
|
||||
->map(fn (InboxMessage $message): string => $message->created_at->format('d.m.').' · '.e($message->subject).': '.e($message->body));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function requests(): Collection
|
||||
{
|
||||
return Booking::query()->whereIn('status', BookingStatus::holding())->with(['guest', 'property'])->orderBy('hold_expires_at')->get()
|
||||
->map(fn (Booking $booking): string => $this->booking($booking).' – '.$booking->status->getLabel().$this->deadline($booking));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function news(CarbonImmutable $since): Collection
|
||||
{
|
||||
$created = Booking::query()->where('created_at', '>=', $since)->with(['guest', 'property'])->oldest()->get()
|
||||
->map(fn (Booking $booking): string => 'Neu: '.$this->booking($booking).' – '.$booking->status->getLabel());
|
||||
$cancelled = Booking::query()->where('status', BookingStatus::Cancelled)->where('created_at', '<', $since)->where('updated_at', '>=', $since)->with(['guest', 'property'])->get()
|
||||
->map(fn (Booking $booking): string => 'Storniert: '.$this->booking($booking));
|
||||
$portal = BlockedPeriod::query()->reservations()->occupying()->where('created_at', '>=', $since)->with(['channel', 'originChannel', 'guest'])->oldest()->get()
|
||||
->map(fn (BlockedPeriod $block): string => 'Portalbuchung '.e($block->bookingChannelLabel()).': '.$this->period($block->starts_on, $block->ends_on).($block->guestName() ? ', '.e($block->guestName()) : ''));
|
||||
|
||||
return $created->concat($cancelled)->concat($portal)->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Arrivals and departures from today on, $days days long, sorted by day (departures first).
|
||||
*
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function stays(int $days): Collection
|
||||
{
|
||||
$from = CarbonImmutable::today();
|
||||
$last = $from->addDays($days - 1);
|
||||
$within = fn (string $start, string $end) => fn (Builder $query) => $query
|
||||
->where(fn (Builder $query) => $query->whereDate($start, '>=', $from)->whereDate($start, '<=', $last))
|
||||
->orWhere(fn (Builder $query) => $query->whereDate($end, '>=', $from)->whereDate($end, '<=', $last));
|
||||
$events = [];
|
||||
|
||||
foreach (Booking::query()->whereIn('status', BookingStatus::occupying())->where($within('arrival', 'departure'))->with(['guest', 'property'])->get() as $booking) {
|
||||
$this->stayEvents($events, $from, $last, $booking->arrival, $booking->departure, $this->booking($booking));
|
||||
}
|
||||
foreach (BlockedPeriod::query()->reservations()->occupying()->where($within('starts_on', 'ends_on'))->with(['channel', 'originChannel', 'guest'])->get() as $block) {
|
||||
$this->stayEvents($events, $from, $last, $block->starts_on, $block->ends_on, e(trim($block->bookingChannelLabel().' '.($block->guestName() ?? ''))));
|
||||
}
|
||||
|
||||
ksort($events);
|
||||
|
||||
return collect(array_values($events));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $events
|
||||
*/
|
||||
private function stayEvents(array &$events, CarbonImmutable $from, CarbonImmutable $last, CarbonImmutable $arrival, CarbonImmutable $departure, string $label): void
|
||||
{
|
||||
if ($departure->betweenIncluded($from, $last)) {
|
||||
$events[$departure->toDateString().'-0-'.count($events)] = $this->day($departure).': Abreise '.$label;
|
||||
}
|
||||
if ($arrival->betweenIncluded($from, $last)) {
|
||||
$events[$arrival->toDateString().'-1-'.count($events)] = $this->day($arrival).': Anreise '.$label.' (bis '.$departure->format('d.m.').')';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function payments(): Collection
|
||||
{
|
||||
return Booking::query()->whereIn('status', [BookingStatus::Confirmed, BookingStatus::DepositPaid])->with(['guest', 'property', 'payments'])->orderBy('arrival')->get()
|
||||
->map(fn (Booking $booking): ?string => match (true) {
|
||||
$booking->status === BookingStatus::Confirmed && $booking->deposit_due_on?->isPast() && $booking->openDeposit() > 0 => $this->booking($booking).' – Anzahlung '.Money::format($booking->openDeposit()).' seit '.$booking->deposit_due_on->format('d.m.').' fällig',
|
||||
$booking->balance_due_on?->isPast() && $booking->openAmount() > 0 => $this->booking($booking).' – offen '.Money::format($booking->openAmount()).' seit '.$booking->balance_due_on->format('d.m.').' fällig',
|
||||
default => null,
|
||||
})
|
||||
->filter()
|
||||
->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function portals(): Collection
|
||||
{
|
||||
$tasks = ChannelTask::query()->open()->with('channel')->oldest()->get()
|
||||
->map(fn (ChannelTask $task): string => 'Aufgabe '.e($task->channel->name).': '.$task->action->getLabel().' '.$task->period());
|
||||
$mails = PortalEmail::query()->where('status', PortalEmailStatus::NeedsReview)->with('channel')->latest('received_at')->get()
|
||||
->map(fn (PortalEmail $mail): string => 'Portal-Mail prüfen ('.e($mail->channel->name).'): '.e($mail->subject));
|
||||
$unclear = BlockedPeriod::query()->unclear()->whereDate('ends_on', '>', today())->with('channel')->orderBy('starts_on')->get()
|
||||
->map(fn (BlockedPeriod $block): string => 'Kalendereintrag klären ('.e($block->channel->name ?? 'Portal').'): '.$this->period($block->starts_on, $block->ends_on)
|
||||
.' · [ansehen]('.PortalOccupationResource::getUrl('view', ['record' => $block->id]).')');
|
||||
$channels = Channel::query()->active()->get()->filter(fn (Channel $channel): bool => $channel->isStale() || filled($channel->last_error))
|
||||
->map(fn (Channel $channel): string => 'Kalenderabgleich '.e($channel->name).': '.e($channel->last_error ?: 'seit längerem kein erfolgreicher Abruf'));
|
||||
|
||||
return $tasks->concat($mails)->concat($unclear)->concat($channels)->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, string>
|
||||
*/
|
||||
private function reviews(): Collection
|
||||
{
|
||||
return Review::query()->where('status', ReviewStatus::Pending)->oldest()->get()
|
||||
->map(fn (Review $review): string => $review->rating.'/5'.($review->title ? ' „'.e($review->title).'“' : '').($review->display_name ? ' von '.e($review->display_name) : ''));
|
||||
}
|
||||
|
||||
private function booking(Booking $booking): string
|
||||
{
|
||||
return '['.$booking->reference.']('.BookingResource::getUrl('view', ['record' => $booking]).') '
|
||||
.e($booking->guest?->full_name ?? 'Gast').', '.$this->period($booking->arrival, $booking->departure)
|
||||
.($this->namesProperty ? ' ('.e($booking->property->name).')' : '');
|
||||
}
|
||||
|
||||
private function deadline(Booking $booking): string
|
||||
{
|
||||
if ($booking->hold_expires_at === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return ', Frist bis '.$booking->hold_expires_at->format('d.m. H:i').' Uhr'.($booking->hold_expires_at->isPast() ? ' (abgelaufen)' : '');
|
||||
}
|
||||
|
||||
private function period(CarbonImmutable $from, CarbonImmutable $until): string
|
||||
{
|
||||
return $from->format('d.m.').'–'.$until->format('d.m.Y');
|
||||
}
|
||||
|
||||
private function day(CarbonImmutable $date): string
|
||||
{
|
||||
return match (true) {
|
||||
$date->isToday() => 'Heute',
|
||||
$date->isTomorrow() => 'Morgen',
|
||||
default => $date->locale('de')->isoFormat('dd DD.MM.'),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Models\Channel;
|
||||
use App\Models\InboxMessage;
|
||||
use Illuminate\Database\UniqueConstraintViolationException;
|
||||
|
||||
/**
|
||||
* Posts findings to the admin inbox ("Postfach"). Each finding has a fingerprint and arrives only once
|
||||
* per landlord, so a check that runs every few minutes does not report a lasting problem again and again.
|
||||
* While the finding is still detected and the message is unread, it is repeated after the landlord's
|
||||
* reminder interval (Settings::reminderIntervalDays(), 0 = never).
|
||||
*/
|
||||
class Inbox
|
||||
{
|
||||
/**
|
||||
* @return InboxMessage|null the message to e-mail now – new (wasRecentlyCreated) or due for a reminder – else null
|
||||
*/
|
||||
public function post(InboxMessageKind $kind, string $fingerprint, string $subject, string $body, ?Channel $channel = null, ?string $actionUrl = null): ?InboxMessage
|
||||
{
|
||||
$fingerprint = $kind->value.':'.$fingerprint;
|
||||
|
||||
$existing = InboxMessage::query()->where('fingerprint', $fingerprint)->first();
|
||||
if ($existing) {
|
||||
$due = $this->reminderDue($existing);
|
||||
$existing->forceFill(['last_seen_at' => now(), ...($due ? ['notified_at' => now()] : [])])->save();
|
||||
|
||||
return $due ? $existing : null;
|
||||
}
|
||||
|
||||
try {
|
||||
return InboxMessage::create([
|
||||
'kind' => $kind,
|
||||
'fingerprint' => $fingerprint,
|
||||
'subject' => mb_substr($subject, 0, 255),
|
||||
'body' => $body,
|
||||
'channel_id' => $channel?->id,
|
||||
'property_id' => $channel?->property_id,
|
||||
'action_url' => $actionUrl,
|
||||
'notified_at' => now(),
|
||||
'last_seen_at' => now(),
|
||||
]);
|
||||
} catch (UniqueConstraintViolationException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unread messages are repeated once the reminder interval has passed; reading one ends its reminders.
|
||||
*/
|
||||
public function reminderDue(InboxMessage $message): bool
|
||||
{
|
||||
$days = Settings::reminderIntervalDays($message->tenant);
|
||||
|
||||
return $days > 0
|
||||
&& ! $message->isRead()
|
||||
&& ($message->notified_at === null || $message->notified_at->lessThanOrEqualTo(now()->subDays($days)));
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,14 @@ public static function mailRedirectFor(?Tenant $tenant): ?string
|
||||
return $tenant?->test_recipient ?: ($recipients[0] ?? null);
|
||||
}
|
||||
|
||||
/**
|
||||
* After how many days an unread, still detected finding is e-mailed again; 0 = only once.
|
||||
*/
|
||||
public static function reminderIntervalDays(?Tenant $tenant = null): int
|
||||
{
|
||||
return (int) (($tenant ?? self::tenant())?->reminder_interval_days ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the redirect of the current landlord to the mailer; called after saving.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Enums\NoticeTone;
|
||||
use App\Models\Notice;
|
||||
|
||||
/**
|
||||
* The banner the website shows right now (BannerResolver): text, optional link, tone.
|
||||
*/
|
||||
final readonly class Banner
|
||||
{
|
||||
public function __construct(
|
||||
public Notice $notice,
|
||||
public string $text,
|
||||
public ?string $linkLabel,
|
||||
public ?string $linkUrl,
|
||||
public NoticeTone $tone,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes;
|
||||
|
||||
use App\Models\Appearance;
|
||||
use App\Models\Notice;
|
||||
use App\Models\Site;
|
||||
use App\Pricing\AdvertisedOffer;
|
||||
use App\Pricing\OfferShowcase;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Picks the banner of a website: among the visible notices for this website (or all websites) that fit the
|
||||
* appearance in effect, the highest priority wins, then the newest. A notice advertising a special offer only
|
||||
* counts while the website advertises that offer; text, dates and link then come from the offer unless the
|
||||
* notice sets its own.
|
||||
*/
|
||||
class BannerResolver
|
||||
{
|
||||
public function __construct(private OfferShowcase $showcase) {}
|
||||
|
||||
public function for(Site $site, ?Appearance $appearance): ?Banner
|
||||
{
|
||||
foreach ($this->candidates($site, $appearance) as $notice) {
|
||||
$banner = $this->banner($notice);
|
||||
if ($banner !== null) {
|
||||
return $banner;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Visible notices for the website and the appearance, in the order they compete.
|
||||
*
|
||||
* @return Collection<int, Notice>
|
||||
*/
|
||||
public function candidates(Site $site, ?Appearance $appearance): Collection
|
||||
{
|
||||
return Notice::query()->visible()
|
||||
->where(fn ($query) => $query->whereNull('site_id')->when($site->exists, fn ($query) => $query->orWhere('site_id', $site->id)))
|
||||
->with('specialOffer.property')
|
||||
->orderByDesc('priority')
|
||||
->latest()
|
||||
->orderByDesc('id')
|
||||
->get()
|
||||
->filter(fn (Notice $notice): bool => $notice->fitsSeason($appearance))
|
||||
->values();
|
||||
}
|
||||
|
||||
private function banner(Notice $notice): ?Banner
|
||||
{
|
||||
if ($notice->special_offer_id === null) {
|
||||
return filled($notice->text)
|
||||
? new Banner($notice, (string) $notice->text, $notice->link_label, $notice->link_label ? ($notice->link_url ?: route('booking.create')) : null, $notice->tone)
|
||||
: null;
|
||||
}
|
||||
|
||||
$offer = $notice->specialOffer;
|
||||
$advertised = $offer?->property
|
||||
? $this->showcase->current($offer->property)->first(fn (AdvertisedOffer $advertised): bool => $advertised->offer->is($offer))
|
||||
: null;
|
||||
if ($advertised === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Banner(
|
||||
$notice,
|
||||
filled($notice->text) ? (string) $notice->text : self::offerText($advertised),
|
||||
$notice->link_label ?: 'Zum Angebot',
|
||||
$notice->link_url ?: $advertised->bookingUrl(),
|
||||
$notice->tone,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* "Kurzfristig frei: 12.11.–15.11. · 15 % günstiger".
|
||||
*/
|
||||
public static function offerText(AdvertisedOffer $advertised): string
|
||||
{
|
||||
$dates = $advertised->arrival && $advertised->departure
|
||||
? ': '.$advertised->arrival->format('d.m.').'–'.$advertised->departure->format('d.m.')
|
||||
: '';
|
||||
|
||||
return $advertised->title.$dates.' · '.$advertised->advantage;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,21 @@
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
|
||||
/**
|
||||
* Availability calendar, live price and booking request (Livewire component App\Livewire\BookingRequest).
|
||||
* Availability calendar, live price and booking request (Livewire component App\Livewire\BookingRequest), optionally
|
||||
* with the three steps of the booking path (request → offer → acceptance) as a graphic.
|
||||
*/
|
||||
class BookingSection extends Section
|
||||
{
|
||||
/** Booking path 1 (KONZEPT §6a) in the guest's words: title => explanation. */
|
||||
public const STEPS = [
|
||||
'Anfrage senden' => 'Kostenlos und unverbindlich. Wir halten den Termin sofort für Sie frei.',
|
||||
'Angebot erhalten' => 'Per E-Mail mit Gesamtpreis und Mietvertrag – in Ruhe prüfen.',
|
||||
'Annehmen' => 'Mit einem Klick im Angebot. Erst dann ist die Buchung verbindlich.',
|
||||
];
|
||||
|
||||
public static function key(): string
|
||||
{
|
||||
return 'booking';
|
||||
@@ -31,6 +40,10 @@ public static function schema(): array
|
||||
return [
|
||||
TextInput::make('heading')->label('Überschrift')->default('Preise & Buchung')->maxLength(120),
|
||||
Textarea::make('text')->label('Text')->rows(2),
|
||||
Toggle::make('show_steps')
|
||||
->label('Ablauf als Grafik zeigen')
|
||||
->helperText('Anfrage → Angebot per E-Mail → Annahme, über dem Kalender.')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -39,6 +52,8 @@ public function data(Theme $theme, array $data): array
|
||||
return [
|
||||
'heading' => $data['heading'] ?? null,
|
||||
'text' => $data['text'] ?? null,
|
||||
'showSteps' => (bool) ($data['show_steps'] ?? true),
|
||||
'steps' => self::STEPS,
|
||||
'property' => $theme->property(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Models\Photo;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -32,23 +31,19 @@ public static function schema(): array
|
||||
return [
|
||||
TextInput::make('title')->label('Überschrift')->required()->maxLength(160),
|
||||
Textarea::make('text')->label('Text')->rows(2),
|
||||
static::photoSelect('photo_id', 'Hintergrundfoto'),
|
||||
static::photoSelect('photo_ids', 'Hintergrundfotos', multiple: true)
|
||||
->helperText('Gezeigt wird das erste, das zum Erscheinungsbild passt. '.self::SEASON_HINT),
|
||||
TextInput::make('button_label')->label('Button-Text')->default('Belegung & Preise')->maxLength(60),
|
||||
static::pageSelect('button_page', 'Button führt zu'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return ['photo_id' => ['label' => 'Hintergrundfoto', 'type' => self::SLOT_SINGLE]];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
return [
|
||||
'title' => $theme->text('cta.title', $data['title'] ?? null),
|
||||
'text' => $theme->text('cta.text', $data['text'] ?? null),
|
||||
'photo' => $this->seasonalPhoto($theme, $data, 'photo_id') ?? (isset($data['photo_id']) ? Photo::find($data['photo_id']) : null),
|
||||
'photo' => $this->chosenPhotos($theme, $data['photo_ids'] ?? [])->first(),
|
||||
'buttonLabel' => $data['button_label'] ?? 'Belegung & Preise',
|
||||
'buttonUrl' => $this->pageUrl($data['button_page'] ?? null) ?? route('booking.create'),
|
||||
];
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Models\Amenity;
|
||||
use App\Models\FloorPlan;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Video;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -52,6 +53,7 @@ public function data(Theme $theme, array $data): array
|
||||
$amenities = Amenity::query()
|
||||
->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['amenity_ids'] ?? [])->unique()->all())
|
||||
->pluck('name', 'id');
|
||||
$videos = $rooms->isEmpty() ? collect() : Video::query()->where('property_id', $plan->property_id)->whereNotNull('chapters')->get();
|
||||
|
||||
return [
|
||||
'heading' => $data['heading'] ?? 'Der Grundriss',
|
||||
@@ -65,6 +67,7 @@ public function data(Theme $theme, array $data): array
|
||||
'points' => collect(FloorPlan::points($room['points']))->map(fn (array $point): string => $point[0].','.$point[1])->implode(' '),
|
||||
'photos' => collect($room['photo_ids'] ?? [])->map(fn ($id) => $photos->get((int) $id))->filter()->values(),
|
||||
'amenities' => collect($room['amenity_ids'] ?? [])->map(fn ($id) => $amenities->get((int) $id))->filter()->values(),
|
||||
'videoChapter' => $videos->map(fn (Video $video): ?array => $video->chapterForRoom($room['name']))->filter()->first(),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Models\Photo;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Photo gallery of one category (or all), opened in a lightbox.
|
||||
@@ -32,26 +32,19 @@ public static function schema(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('heading')->label('Überschrift')->maxLength(120),
|
||||
Select::make('category')->label('Bilder')->options(['all' => 'Alle', ...collect(PhotoCategory::cases())->mapWithKeys(fn (PhotoCategory $category): array => [$category->value => $category->getLabel()])->all()])->default('all'),
|
||||
...static::photoSourceFields('Automatisch nach Kategorie'),
|
||||
Select::make('category')->label('Kategorie')->visible(fn (Get $get): bool => $get('photo_source') !== 'selection')->options(['all' => 'Alle', ...collect(PhotoCategory::forGalleries())->mapWithKeys(fn (PhotoCategory $category): array => [$category->value => $category->getLabel()])->all()])->default('all'),
|
||||
TextInput::make('limit')->label('Anzahl (leer = alle)')->integer()->minValue(1),
|
||||
];
|
||||
}
|
||||
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return ['photo_ids' => ['label' => 'Galerie', 'type' => self::SLOT_COLLECTION]];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
$category = PhotoCategory::tryFrom($data['category'] ?? '');
|
||||
|
||||
return [
|
||||
'heading' => $data['heading'] ?? null,
|
||||
'photos' => $this->withSeasonalPhotos($theme, $data, 'photo_ids', Photo::query()->published()->with('media')
|
||||
->when($category, fn ($query) => $query->where('category', $category))
|
||||
->when(filled($data['limit'] ?? null), fn ($query) => $query->limit((int) $data['limit']))
|
||||
->get()),
|
||||
'photos' => $this->sourcedPhotos($theme, $data, $category, filled($data['limit'] ?? null) ? (int) $data['limit'] : null),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,18 @@
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Models\Photo;
|
||||
use App\Availability\NextFreeStays;
|
||||
use App\Pricing\OfferShowcase;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Large photo with headline and the availability search. Seasonal appearances replace photo and texts.
|
||||
* Large photo (or a silent video loop) with headline, the availability search and the next free dates.
|
||||
* Seasonal appearances replace photo and texts.
|
||||
*/
|
||||
class HeroSection extends Section
|
||||
{
|
||||
@@ -35,8 +38,22 @@ public static function schema(): array
|
||||
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
||||
TextInput::make('title')->label('Überschrift')->helperText('*Wort* wird hervorgehoben (kursiv).')->required()->maxLength(160),
|
||||
Textarea::make('text')->label('Text')->rows(2)->maxLength(400),
|
||||
static::photoSelect('photo_id', 'Foto (wenn das Erscheinungsbild keins vorgibt)'),
|
||||
static::photoSelect('photo_ids', 'Fotos', multiple: true)
|
||||
->helperText('Gezeigt wird das erste Foto, das zum Erscheinungsbild passt; leer = automatisch ein Foto der Wohnung. '.self::SEASON_HINT),
|
||||
static::videoSelect('video_id', 'Video statt Foto')
|
||||
->helperText('Läuft stumm in Schleife an der Stelle des Fotos (Webseite › Videos). Bei „Bewegung reduzieren“ und langsamer Verbindung bleibt das Standbild des Videos stehen.'),
|
||||
Toggle::make('show_search')->label('Verfügbarkeitssuche anzeigen')->default(true),
|
||||
Toggle::make('show_free_dates')
|
||||
->label('Nächste freie Termine zeigen')
|
||||
->helperText('Bis zu drei buchbare Zeiträume mit Gesamtpreis; ein Klick öffnet die Anfrage mit diesen Daten.')
|
||||
->default(true)
|
||||
->live(),
|
||||
Select::make('free_dates_nights')
|
||||
->label('Mindestens … Nächte')
|
||||
->options(array_combine(range(2, 7), array_map(fn (int $nights): string => "{$nights} Nächte", range(2, 7))))
|
||||
->default(3)
|
||||
->selectablePlaceholder(false)
|
||||
->visible(fn (Get $get): bool => (bool) $get('show_free_dates')),
|
||||
Toggle::make('show_offer')
|
||||
->label('Hervorgehobenes Sonderangebot im Titelbereich zeigen')
|
||||
->helperText('Das wichtigste als „hervorgehoben“ markierte Angebot, sofern gerade eins gilt.')
|
||||
@@ -44,26 +61,26 @@ public static function schema(): array
|
||||
];
|
||||
}
|
||||
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return ['photo_id' => ['label' => 'Foto', 'type' => self::SLOT_SINGLE]];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
$fallback = isset($data['photo_id']) ? Photo::find($data['photo_id']) : Photo::query()->published()->first();
|
||||
$featuredOffer = ($data['show_offer'] ?? true) && $theme->property()
|
||||
? app(OfferShowcase::class)->current($theme->property(), limit: 1, featuredOnly: true)->first()
|
||||
$property = $theme->property();
|
||||
$featuredOffer = ($data['show_offer'] ?? true) && $property
|
||||
? app(OfferShowcase::class)->current($property, limit: 1, featuredOnly: true)->first()
|
||||
: null;
|
||||
$freeStays = ($data['show_free_dates'] ?? false) && $property
|
||||
? app(NextFreeStays::class)->for($property, nights: (int) ($data['free_dates_nights'] ?? 3))
|
||||
: [];
|
||||
|
||||
return [
|
||||
'eyebrow' => $theme->text('hero.eyebrow', $data['eyebrow'] ?? null),
|
||||
'title' => $theme->text('hero.title', $data['title'] ?? $theme->site->name),
|
||||
'text' => $theme->text('hero.text', $data['text'] ?? null),
|
||||
'photo' => $this->seasonalPhoto($theme, $data, 'photo_id') ?? $theme->heroPhoto($fallback),
|
||||
'photo' => $this->chosenPhotos($theme, $data['photo_ids'] ?? [])->first() ?? $this->automaticPhotos($theme, limit: 1)->first(),
|
||||
'video' => $this->video($data['video_id'] ?? null),
|
||||
'freeStays' => $freeStays,
|
||||
'featuredOffer' => $featuredOffer,
|
||||
'showSearch' => (bool) ($data['show_search'] ?? true),
|
||||
'property' => $theme->property(),
|
||||
'property' => $property,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,12 @@
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Models\Photo;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
|
||||
/**
|
||||
* Location: text, photos of the area and a map link (no embedded third-party map, so no consent needed).
|
||||
@@ -35,15 +36,11 @@ public static function schema(): array
|
||||
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(160),
|
||||
RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList']]),
|
||||
Toggle::make('show_photos')->label('Bilder der Umgebung zeigen')->default(true),
|
||||
Toggle::make('show_photos')->label('Bilder zeigen')->default(true)->live(),
|
||||
Group::make(static::photoSourceFields('Automatisch: Fotos der Umgebung'))->visible(fn (Get $get): bool => (bool) $get('show_photos')),
|
||||
];
|
||||
}
|
||||
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return ['photo_ids' => ['label' => 'Bilder der Umgebung', 'type' => self::SLOT_COLLECTION]];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
$address = $theme->property()?->address;
|
||||
@@ -55,7 +52,7 @@ public function data(Theme $theme, array $data): array
|
||||
'address' => $address,
|
||||
'mapUrl' => $address ? 'https://www.openstreetmap.org/search?query='.rawurlencode($address) : null,
|
||||
'photos' => ($data['show_photos'] ?? true)
|
||||
? $this->withSeasonalPhotos($theme, $data, 'photo_ids', Photo::query()->published()->with('media')->where('category', PhotoCategory::Area)->limit(6)->get())
|
||||
? $this->sourcedPhotos($theme, $data, PhotoCategory::Area, 6)
|
||||
: collect(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Enums\PhotoCategory;
|
||||
use App\Filament\Forms\Components\PhotoSelect;
|
||||
use App\Models\Page;
|
||||
use App\Models\Photo;
|
||||
use App\Models\Video;
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\RichEditor\RichContentRenderer;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@@ -18,14 +22,8 @@
|
||||
*/
|
||||
abstract class Section
|
||||
{
|
||||
/** One photo (field holds a photo id). */
|
||||
public const SLOT_SINGLE = 'single';
|
||||
|
||||
/** Several chosen photos (field holds a list of ids). */
|
||||
public const SLOT_MULTIPLE = 'multiple';
|
||||
|
||||
/** Photos picked automatically (e.g. by category); an appearance may replace or precede them. */
|
||||
public const SLOT_COLLECTION = 'collection';
|
||||
/** How photos follow the seasons – shown below every photo choice. */
|
||||
public const SEASON_HINT = 'Fotos mit Saison (Webseite › Fotos › „Zeigen in“) erscheinen nur in ihrem Erscheinungsbild, alle anderen ganzjährig.';
|
||||
|
||||
abstract public static function key(): string;
|
||||
|
||||
@@ -49,16 +47,6 @@ public static function schema(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Photo places an appearance can fill with seasonal photos ("Bilder je Baustein").
|
||||
*
|
||||
* @return array<string, array{label: string, type: string, max?: int}>
|
||||
*/
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Short text identifying a placed section in admin lists, e.g. its heading.
|
||||
*
|
||||
@@ -108,52 +96,63 @@ protected function photos(?array $ids): Collection
|
||||
}
|
||||
|
||||
/**
|
||||
* The seasonal photo the active appearance sets for a single slot of this placed section.
|
||||
* Chosen photos in the editor's order: published and fitting the season in effect.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function seasonalPhoto(Theme $theme, array $data, string $slot): ?Photo
|
||||
{
|
||||
return $this->seasonalPhotos($theme, $data, $slot)?->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* The seasonal photos the active appearance sets for a slot of this placed section, null if none.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return Collection<int, Photo>|null
|
||||
*/
|
||||
protected function seasonalPhotos(Theme $theme, array $data, string $slot): ?Collection
|
||||
{
|
||||
$ids = $theme->sectionPhotoIds($data['id'] ?? null, $slot);
|
||||
if ($ids === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$photos = $this->photos($ids);
|
||||
|
||||
return $photos->isEmpty() ? null : $photos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos of a collection slot: the automatic photos, replaced or preceded by the seasonal ones.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @param Collection<int, Photo> $automatic
|
||||
* @param list<int|string>|null $ids
|
||||
* @return Collection<int, Photo>
|
||||
*/
|
||||
protected function withSeasonalPhotos(Theme $theme, array $data, string $slot, Collection $automatic): Collection
|
||||
protected function chosenPhotos(Theme $theme, ?array $ids): Collection
|
||||
{
|
||||
$seasonal = $this->seasonalPhotos($theme, $data, $slot);
|
||||
if ($seasonal === null) {
|
||||
return $automatic;
|
||||
return $this->photos($ids)->filter(fn (Photo $photo): bool => $photo->fitsSeason($theme->appearance))->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos picked automatically for the section's apartment and the season (Photo::automatic).
|
||||
*
|
||||
* @return Collection<int, Photo>
|
||||
*/
|
||||
protected function automaticPhotos(Theme $theme, ?PhotoCategory $category = null, ?int $limit = null): Collection
|
||||
{
|
||||
$photos = Photo::automatic($theme->property(), $theme->appearance, $category);
|
||||
|
||||
return $limit !== null ? $photos->take($limit)->values() : $photos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Photos of a section that offers "automatisch" or "eigene Auswahl" (fields from photoSourceFields()).
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return Collection<int, Photo>
|
||||
*/
|
||||
protected function sourcedPhotos(Theme $theme, array $data, ?PhotoCategory $category = null, ?int $limit = null): Collection
|
||||
{
|
||||
if (($data['photo_source'] ?? 'auto') === 'selection') {
|
||||
$photos = $this->chosenPhotos($theme, $data['photo_ids'] ?? []);
|
||||
|
||||
return $limit !== null ? $photos->take($limit)->values() : $photos;
|
||||
}
|
||||
|
||||
if ($theme->sectionPhotoMode($data['id'] ?? null) === 'prepend') {
|
||||
return $seasonal->merge($automatic)->unique('id')->values();
|
||||
}
|
||||
return $this->automaticPhotos($theme, $category, $limit);
|
||||
}
|
||||
|
||||
return $seasonal;
|
||||
/**
|
||||
* "Automatisch" or "Eigene Auswahl" plus the selection field, shown only for a selection.
|
||||
*
|
||||
* @return list<Component>
|
||||
*/
|
||||
protected static function photoSourceFields(string $automaticLabel): array
|
||||
{
|
||||
return [
|
||||
Radio::make('photo_source')
|
||||
->label('Bilder')
|
||||
->options(['auto' => $automaticLabel, 'selection' => 'Eigene Auswahl'])
|
||||
->default('auto')
|
||||
->inline()
|
||||
->live(),
|
||||
static::photoSelect('photo_ids', 'Ausgewählte Bilder', multiple: true)
|
||||
->helperText(self::SEASON_HINT)
|
||||
->visible(fn (Get $get): bool => $get('photo_source') === 'selection'),
|
||||
];
|
||||
}
|
||||
|
||||
protected function pageUrl(?string $slug): ?string
|
||||
@@ -175,6 +174,27 @@ protected static function photoSelect(string $name, string $label, bool $multipl
|
||||
->multiple($multiple);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select field listing the website videos (Admin › Webseite › Videos).
|
||||
*/
|
||||
protected static function videoSelect(string $name, string $label): Select
|
||||
{
|
||||
return Select::make($name)
|
||||
->label($label)
|
||||
->options(fn (): array => Video::query()->orderBy('title')->pluck('title', 'id')->all())
|
||||
->placeholder('– kein Video –');
|
||||
}
|
||||
|
||||
/**
|
||||
* The chosen video, if it still exists and has a file.
|
||||
*/
|
||||
protected function video(mixed $id): ?Video
|
||||
{
|
||||
$video = filled($id) ? Video::query()->with('media')->find($id) : null;
|
||||
|
||||
return $video?->url() ? $video : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select field listing the pages of the site, for links.
|
||||
*/
|
||||
|
||||
@@ -33,25 +33,21 @@ public static function schema(): array
|
||||
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(160),
|
||||
RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList', 'orderedList']]),
|
||||
static::photoSelect('photo_ids', 'Bilder (bis zu 3)', multiple: true)->maxItems(3),
|
||||
static::photoSelect('photo_ids', 'Bilder', multiple: true)->maxItems(9)
|
||||
->helperText('Gezeigt werden die ersten drei, die zum Erscheinungsbild passen. '.self::SEASON_HINT),
|
||||
Select::make('image_position')->label('Bilder')->options(['right' => 'rechts', 'left' => 'links'])->default('right'),
|
||||
TextInput::make('link_label')->label('Link-Text')->maxLength(80),
|
||||
static::pageSelect('link_page', 'Link zur Seite'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function photoSlots(): array
|
||||
{
|
||||
return ['photo_ids' => ['label' => 'Bilder', 'type' => self::SLOT_MULTIPLE, 'max' => 3]];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
return [
|
||||
'eyebrow' => $data['eyebrow'] ?? null,
|
||||
'heading' => $data['heading'] ?? '',
|
||||
'text' => $this->html($data['text'] ?? null),
|
||||
'photos' => $this->seasonalPhotos($theme, $data, 'photo_ids') ?? $this->photos($data['photo_ids'] ?? []),
|
||||
'photos' => $this->chosenPhotos($theme, $data['photo_ids'] ?? [])->take(3)->values(),
|
||||
'imagePosition' => $data['image_position'] ?? 'right',
|
||||
'linkLabel' => $data['link_label'] ?? null,
|
||||
'linkUrl' => $this->pageUrl($data['link_page'] ?? null),
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Themes\Sections;
|
||||
|
||||
use App\Themes\Theme;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
|
||||
/**
|
||||
* A video tour through the apartment: plays only when a guest starts it, chapters jump to a room. Floor plan
|
||||
* rooms named in a chapter offer "Im Video ansehen" when the tour is on the same page.
|
||||
*/
|
||||
class TourSection extends Section
|
||||
{
|
||||
public const LAYOUTS = [
|
||||
'wide' => 'Video in voller Breite, Text darüber',
|
||||
'left' => 'Video links, Text und Kapitel rechts',
|
||||
'right' => 'Video rechts, Text und Kapitel links',
|
||||
];
|
||||
|
||||
public static function key(): string
|
||||
{
|
||||
return 'tour';
|
||||
}
|
||||
|
||||
public static function label(): string
|
||||
{
|
||||
return 'Rundgang (Video)';
|
||||
}
|
||||
|
||||
public static function icon(): string
|
||||
{
|
||||
return 'heroicon-o-film';
|
||||
}
|
||||
|
||||
public static function schema(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
||||
TextInput::make('heading')->label('Überschrift')->default('Ein Rundgang durch die Wohnung')->maxLength(160),
|
||||
Textarea::make('text')->label('Text')->rows(3)->maxLength(600),
|
||||
static::videoSelect('video_id', 'Video')
|
||||
->helperText('Webseite › Videos. Das Video lädt erst, wenn Besucher es starten – die Seite bleibt schnell.')
|
||||
->required(),
|
||||
Radio::make('layout')
|
||||
->label('Anordnung')
|
||||
->options(self::LAYOUTS)
|
||||
->default('left')
|
||||
->required(),
|
||||
Toggle::make('show_chapters')
|
||||
->label('Kapitel als Knöpfe zeigen')
|
||||
->helperText('Die Kapitel pflegen Sie am Video.')
|
||||
->default(true),
|
||||
];
|
||||
}
|
||||
|
||||
public function data(Theme $theme, array $data): array
|
||||
{
|
||||
$video = $this->video($data['video_id'] ?? null);
|
||||
|
||||
return [
|
||||
'eyebrow' => $data['eyebrow'] ?? null,
|
||||
'heading' => $data['heading'] ?? null,
|
||||
'text' => $data['text'] ?? null,
|
||||
'video' => $video,
|
||||
'chapters' => ($data['show_chapters'] ?? true) && $video ? $video->chapterList() : [],
|
||||
'layout' => array_key_exists($data['layout'] ?? '', self::LAYOUTS) ? $data['layout'] : 'left',
|
||||
];
|
||||
}
|
||||
}
|
||||
+27
-21
@@ -23,6 +23,10 @@ class Theme
|
||||
|
||||
private bool $propertyResolved = false;
|
||||
|
||||
private ?Banner $banner = null;
|
||||
|
||||
private bool $bannerResolved = false;
|
||||
|
||||
/** @var array<string, Collection<int, Page>> */
|
||||
private array $menus = [];
|
||||
|
||||
@@ -95,35 +99,37 @@ public function text(string $key, ?string $fallback = null): ?string
|
||||
return $this->appearance?->override($key) ?? $fallback;
|
||||
}
|
||||
|
||||
public function heroPhoto(?Photo $fallback = null): ?Photo
|
||||
/**
|
||||
* Picture for link previews (social media, messengers) and search engines: the first photo of the page's
|
||||
* title area that fits the season, else an automatic photo of the apartment.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections the page's placed sections
|
||||
*/
|
||||
public function sharePhoto(array $sections = []): ?Photo
|
||||
{
|
||||
return $this->appearance?->heroPhoto ?? $fallback;
|
||||
$chosen = collect($sections)
|
||||
->filter(fn (array $section): bool => ($section['type'] ?? null) === 'hero')
|
||||
->flatMap(fn (array $section): array => (array) ($section['data']['photo_ids'] ?? []))
|
||||
->map(fn ($id): int => (int) $id)
|
||||
->all();
|
||||
$photos = Photo::query()->published()->whereKey($chosen)->with('media')->get()->keyBy('id');
|
||||
$first = collect($chosen)->map(fn (int $id): ?Photo => $photos->get($id))
|
||||
->first(fn (?Photo $photo): bool => $photo?->fitsSeason($this->appearance) ?? false);
|
||||
|
||||
return $first ?? Photo::automatic($this->property(), $this->appearance)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Photo ids the active appearance sets for a slot of a placed section ("Bilder je Baustein").
|
||||
*
|
||||
* @return list<int>
|
||||
* The banner at the top of the website right now (Admin › Webseite › Banner & Hinweise), or null.
|
||||
*/
|
||||
public function sectionPhotoIds(?string $sectionId, string $slot): array
|
||||
public function banner(): ?Banner
|
||||
{
|
||||
if (blank($sectionId) || $this->appearance === null) {
|
||||
return [];
|
||||
if (! $this->bannerResolved) {
|
||||
$this->banner = app(BannerResolver::class)->for($this->site, $this->appearance);
|
||||
$this->bannerResolved = true;
|
||||
}
|
||||
|
||||
$ids = $this->appearance->section_photos[$sectionId][$slot] ?? null;
|
||||
|
||||
return array_values(array_map('intval', array_filter((array) $ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether seasonal photos replace the automatic photos of a section ('replace') or come first ('prepend').
|
||||
*/
|
||||
public function sectionPhotoMode(?string $sectionId): string
|
||||
{
|
||||
$mode = $sectionId ? ($this->appearance?->section_photos[$sectionId]['mode'] ?? null) : null;
|
||||
|
||||
return $mode === 'prepend' ? 'prepend' : 'replace';
|
||||
return $this->banner;
|
||||
}
|
||||
|
||||
public function appearanceKey(): string
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Livewire – only what differs from the package defaults
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Livewire merges this file over its own config key by key. Uploads in the admin (photos up to 25 MB,
|
||||
| videos up to 100 MB, see App\Models\Video::MAX_KB) need a larger temporary upload than the 12 MB default;
|
||||
| each form field still sets its own, smaller limit. Strato accepts request bodies up to 128 MB.
|
||||
|
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
'temporary_file_upload' => [
|
||||
'disk' => env('LIVEWIRE_TEMPORARY_FILE_UPLOAD_DISK'),
|
||||
'rules' => ['required', 'file', 'max:102400'],
|
||||
'directory' => null,
|
||||
'middleware' => null,
|
||||
'preview_mimes' => [
|
||||
'png', 'gif', 'bmp', 'svg', 'wav', 'mp4',
|
||||
'mov', 'avi', 'wmv', 'mp3', 'm4a',
|
||||
'jpg', 'jpeg', 'mpga', 'webp', 'wma',
|
||||
],
|
||||
'max_upload_time' => 15,
|
||||
'cleanup' => true,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -50,7 +50,7 @@
|
||||
* 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
|
||||
'max_file_size' => 1024 * 1024 * 100, // 100MB: website videos (App\Models\Video::MAX_KB); Strato accepts uploads up to 128 MB
|
||||
|
||||
/*
|
||||
* Uploads whose file name contains any of these extensions will be rejected.
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
Sections\GallerySection::class,
|
||||
Sections\AmenitiesSection::class,
|
||||
Sections\FloorPlanSection::class,
|
||||
Sections\TourSection::class,
|
||||
Sections\LocationSection::class,
|
||||
Sections\PricesSection::class,
|
||||
Sections\OffersSection::class,
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\InboxMessageKind;
|
||||
use App\Models\InboxMessage;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<InboxMessage>
|
||||
*/
|
||||
class InboxMessageFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'kind' => InboxMessageKind::ChannelConflict,
|
||||
'fingerprint' => fake()->unique()->uuid(),
|
||||
'subject' => fake()->sentence(4),
|
||||
'body' => fake()->sentence(),
|
||||
];
|
||||
}
|
||||
|
||||
public function read(): static
|
||||
{
|
||||
return $this->state(fn (): array => ['read_at' => now()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Video;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Video>
|
||||
*/
|
||||
class VideoFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'title' => fake()->sentence(3),
|
||||
'chapters' => null,
|
||||
];
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('blocked_periods', function (Blueprint $table) {
|
||||
$table->boolean('representation_automatic')->default(false);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
if (DB::table('blocked_periods')->where('representation_automatic', true)->exists()) {
|
||||
throw new RuntimeException('Automatische Kalenderspiegelungen zuerst auflösen; ihre Kennzeichnung darf nicht verloren gehen.');
|
||||
}
|
||||
Schema::table('blocked_periods', function (Blueprint $table) {
|
||||
$table->dropColumn('representation_automatic');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loaded 100 of 146 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user