mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
🌍 Scope lecturers and courses by country across views and enhance sidebar with dynamic country flags
This commit is contained in:
@@ -66,14 +66,24 @@
|
|||||||
<flux:navlist.item icon="academic-cap" :href="route_with_country('courses.index')"
|
<flux:navlist.item icon="academic-cap" :href="route_with_country('courses.index')"
|
||||||
:current="request()->routeIs('courses.index')"
|
:current="request()->routeIs('courses.index')"
|
||||||
wire:navigate
|
wire:navigate
|
||||||
badge="{{ \App\Models\Course::query()->count() }}">
|
badge="{{ \App\Models\Course::query()->whereHas('courseEvents.venue.city.country', fn($query) => $query->where('countries.code', request()->route('country')))->count() }}">
|
||||||
{{ __('Kurse') }}
|
<div class="flex items-center space-x-2">
|
||||||
|
<span>{{ __('Kurse') }}</span>
|
||||||
|
<img alt="{{ request()->route('country') }}"
|
||||||
|
src="{{ asset('vendor/blade-flags/country-'.request()->route('country').'.svg') }}"
|
||||||
|
width="24" height="12"/>
|
||||||
|
</div>
|
||||||
</flux:navlist.item>
|
</flux:navlist.item>
|
||||||
<flux:navlist.item icon="user" :href="route_with_country('lecturers.index')"
|
<flux:navlist.item icon="user" :href="route_with_country('lecturers.index')"
|
||||||
:current="request()->routeIs('lecturers.index')"
|
:current="request()->routeIs('lecturers.index')"
|
||||||
wire:navigate
|
wire:navigate
|
||||||
badge="{{ \App\Models\Lecturer::query()->count() }}">
|
badge="{{ \App\Models\Lecturer::query()->whereHas('coursesEvents.venue.city.country', fn($query) => $query->where('countries.code', request()->route('country')))->count() }}">
|
||||||
{{ __('Dozenten') }}
|
<div class="flex items-center space-x-2">
|
||||||
|
<span>{{ __('Dozenten') }}</span>
|
||||||
|
<img alt="{{ request()->route('country') }}"
|
||||||
|
src="{{ asset('vendor/blade-flags/country-'.request()->route('country').'.svg') }}"
|
||||||
|
width="24" height="12"/>
|
||||||
|
</div>
|
||||||
</flux:navlist.item>
|
</flux:navlist.item>
|
||||||
</flux:navlist.group>
|
</flux:navlist.group>
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +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')))
|
||||||
->orderByDesc('has_future_events')
|
->orderByDesc('has_future_events')
|
||||||
->paginate(15),
|
->paginate(15),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ class extends Component {
|
|||||||
public function mount(): void
|
public function mount(): void
|
||||||
{
|
{
|
||||||
$this->country = request()->route('country', config('app.domain_country'));
|
$this->country = request()->route('country', config('app.domain_country'));
|
||||||
|
$this->course->load([
|
||||||
|
'courseEvents.registrations',
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function with(): array
|
public function with(): array
|
||||||
@@ -26,7 +29,10 @@ class extends Component {
|
|||||||
'course' => $this->course->load('lecturer'),
|
'course' => $this->course->load('lecturer'),
|
||||||
'events' => $this->course
|
'events' => $this->course
|
||||||
->courseEvents()
|
->courseEvents()
|
||||||
->with(['venue.city'])
|
->with([
|
||||||
|
'venue.city',
|
||||||
|
'registrations',
|
||||||
|
])
|
||||||
->where('from', '>=', now())
|
->where('from', '>=', now())
|
||||||
->orderBy('from', 'asc')
|
->orderBy('from', 'asc')
|
||||||
->get(),
|
->get(),
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ class extends Component {
|
|||||||
->withCount([
|
->withCount([
|
||||||
'coursesEvents as future_events_count' => fn($query) => $query->where('from', '>=', now()),
|
'coursesEvents as future_events_count' => fn($query) => $query->where('from', '>=', now()),
|
||||||
])
|
])
|
||||||
|
->whereHas('coursesEvents')
|
||||||
|
->whereHas('coursesEvents.venue.city.country',
|
||||||
|
fn($query) => $query->where('countries.code', $this->country))
|
||||||
->when($this->search, fn($query)
|
->when($this->search, fn($query)
|
||||||
=> $query
|
=> $query
|
||||||
->where('name', 'ilike', '%'.$this->search.'%')
|
->where('name', 'ilike', '%'.$this->search.'%')
|
||||||
|
|||||||
Reference in New Issue
Block a user