all meetups

This commit is contained in:
Benjamin Takats
2023-01-17 19:54:32 +01:00
parent b7e0b64ebe
commit 42a8f4b65b
4 changed files with 12 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Http\Livewire\Meetup;
use App\Models\Country;
use App\Models\Meetup;
use App\Models\MeetupEvent;
use Livewire\Component;
use RalphJSmit\Laravel\SEO\Support\SEOData;

View File

@@ -10,7 +10,7 @@ use Rappasoft\LaravelLivewireTables\Views\Filters\TextFilter;
class MeetupTable extends DataTableComponent
{
public string $country;
public ?string $country = null;
protected $model = Meetup::class;
@@ -69,7 +69,8 @@ class MeetupTable extends DataTableComponent
public function builder(): Builder
{
return Meetup::query()
->whereHas('city.country', fn($query) => $query->where('code', $this->country))
->when($this->country, fn($query, $country) => $query->whereHas('city.country',
fn($query) => $query->where('code', $this->country)))
->withCount([
'users',
'meetupEvents' => fn($query) => $query->where('start', '>=', now()),