Wohnungsumschalter im Verwaltungsmenue und wohnungsbezogene Listen
Oben im Seitenmenue waehlt man die Wohnung; Listen, neue Eintraege, Belegungsplan und Preise & Angebote folgen ihr. Ein geoeffneter Eintrag einer anderen Wohnung schaltet auf diese um. Galerie und Ersatz-Titelbild der Website zeigen nur Fotos der Wohnung des Bausteins und Fotos ohne Wohnung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e74033a958
commit
8bcda9a4bc
37 files changed
+520
-35
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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]
|
||||
|
||||
@@ -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)'),
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,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())
|
||||
->unique(ignoreRecord: true)
|
||||
->validationMessages(['unique' => 'Für diese Wohnung gibt es schon einen Grundriss.'])
|
||||
->required()
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Enums\PhotoCategory;
|
||||
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,7 +45,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())
|
||||
->placeholder('– keine (z. B. Umgebung) –'),
|
||||
Toggle::make('is_published')
|
||||
->label('Auf der Webseite zeigen')
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user