->when($this->country

This commit is contained in:
Benjamin Takats
2023-01-19 12:40:19 +01:00
parent 8ef4f018d0
commit d125c5d847

View File

@@ -69,13 +69,13 @@ class MeetupTable extends DataTableComponent
public function builder(): Builder public function builder(): Builder
{ {
return Meetup::query() return Meetup::query()
->when($this->country, fn($query, $country) => $query->whereHas('city.country',
fn($query) => $query->where('code', $this->country)))
->with([ ->with([
'users', 'users',
'city.country', 'city.country',
'meetupEvents', 'meetupEvents',
]) ])
->when($this->country, fn($query, $country) => $query->whereHas('city.country',
fn($query) => $query->where('code', $this->country)))
->withCount([ ->withCount([
'users', 'users',
'meetupEvents' => fn($query) => $query->where('start', '>=', now()), 'meetupEvents' => fn($query) => $query->where('start', '>=', now()),