🌍 Scope cities, venues, and courses by country across views and refine sidebar counts accordingly

This commit is contained in:
HolgerHatGarKeineNode
2025-12-05 19:06:55 +01:00
parent c9971144da
commit 0b6853a6ff
3 changed files with 6 additions and 4 deletions

View File

@@ -93,13 +93,13 @@
<flux:navlist.item icon="building-office-2" :href="route_with_country('cities.index')" <flux:navlist.item icon="building-office-2" :href="route_with_country('cities.index')"
:current="request()->routeIs('cities.index')" :current="request()->routeIs('cities.index')"
wire:navigate wire:navigate
badge="{{ \App\Models\City::query()->count() }}"> badge="{{ \App\Models\City::query()->whereHas('country', fn($query) => $query->where('countries.code', request()->route('country')))->count() }}">
{{ __('Städte/Gebiete') }} {{ __('Städte/Gebiete') }}
</flux:navlist.item> </flux:navlist.item>
<flux:navlist.item icon="map-pin" :href="route_with_country('venues.index')" <flux:navlist.item icon="map-pin" :href="route_with_country('venues.index')"
:current="request()->routeIs('venues.index')" :current="request()->routeIs('venues.index')"
wire:navigate wire:navigate
badge="{{ \App\Models\Venue::query()->count() }}"> badge="{{ \App\Models\Venue::query()->whereHas('city.country', fn($query) => $query->where('countries.code', request()->route('country')))->count() }}">
{{ __('Veranstaltungsorte') }} {{ __('Veranstaltungsorte') }}
</flux:navlist.item> </flux:navlist.item>
</flux:navlist.group> </flux:navlist.group>

View File

@@ -23,10 +23,12 @@ class extends Component {
public function with(): array public function with(): array
{ {
return [ return [
'cities' => City::with(['country', 'createdBy']) 'cities' => City::query()
->with(['country', 'createdBy'])
->when($this->search, fn($query) ->when($this->search, fn($query)
=> $query->where('name', 'ilike', '%'.$this->search.'%'), => $query->where('name', 'ilike', '%'.$this->search.'%'),
) )
->whereHas('country', fn($query) => $query->where('countries.code', $this->country))
->orderBy('name') ->orderBy('name')
->paginate(15), ->paginate(15),
]; ];

View File

@@ -32,7 +32,7 @@ class extends Component {
->where('name', 'ilike', '%'.$this->search.'%') ->where('name', 'ilike', '%'.$this->search.'%')
->orWhere('description', 'ilike', '%'.$this->search.'%'), ->orWhere('description', 'ilike', '%'.$this->search.'%'),
) )
->whereHas('courseEvents.venue.city.country', fn($query) => $query->where('countries.code', request()->route('country'))) ->whereHas('courseEvents.venue.city.country', fn($query) => $query->where('countries.code', $this->country))
->orderByDesc('has_future_events') ->orderByDesc('has_future_events')
->paginate(15), ->paginate(15),
]; ];