user()?->hasRole(UserRole::Admin); } public function mount(): void { $this->bookingId = is_numeric(request()->query('vorgang')) ? (int) request()->query('vorgang') : null; } /** * Every way a case of a property can come in, with the profile that would apply now. * * @return list}> */ public function matrix(): array { $settings = app(ProcessSettings::class); return Property::query()->orderBy('name')->get()->map(function (Property $property) use ($settings): array { $columns = [['label' => 'Direkte Anfrage (Webseite, Telefon)', 'profile' => $settings->resolve($property, null, IntakeKind::Inquiry)]]; foreach (Channel::query()->where('property_id', $property->id)->orderBy('name')->get() as $channel) { $columns[] = ['label' => $channel->name.' – Anfrage', 'profile' => $settings->resolve($property, $channel, IntakeKind::Inquiry)]; $columns[] = ['label' => $channel->name.' – feste Buchung', 'profile' => $settings->resolve($property, $channel, IntakeKind::Booking)]; } $columns[] = ['label' => 'Eigene Nutzung / Sperre (A6)', 'profile' => $settings->resolve($property, null, IntakeKind::Internal)]; return ['property' => $property, 'columns' => $columns]; })->all(); } /** * @return list */ public function settings(): array { return ProcessSetting::cases(); } public function describe(ProcessSetting $setting, ProcessProfile $profile): string { $value = $profile->value($setting); if ($setting === ProcessSetting::ContractTemplate) { return $value === null ? 'Texte der Webseite' : (ContractTemplate::query()->find($value)?->label() ?? 'Vorlage Nr. '.$value); } return $setting->describe($value); } /** * Where a setting is changed in the application. */ public static function where(ProcessSetting $setting): string { return $setting === ProcessSetting::ContractTemplate ? 'Wohnung › Abweichende Abwicklung (Experte) bzw. Portal › Anfragen / Feste Buchungen' : 'System › So arbeite ich; Abweichung: Wohnung (Experte), Portal je Anfrage/feste Buchung'.($setting->channelIntakes() === [] ? ' (kein Portal)' : ''); } /** * Recent cases to check. * * @return array */ public function cases(): array { return Booking::query()->with('guest')->latest('id')->limit(60)->get() ->mapWithKeys(fn (Booking $booking): array => [$booking->id => $booking->reference.' · '.$booking->guestName().' · '.$booking->caseType()->value])->all(); } public function booking(): ?Booking { return $this->bookingId ? Booking::query()->find($this->bookingId) : null; } }