diff --git a/resources/views/livewire/cities/create.blade.php b/resources/views/livewire/cities/create.blade.php index 753c2f7..4a52294 100644 --- a/resources/views/livewire/cities/create.blade.php +++ b/resources/views/livewire/cities/create.blade.php @@ -11,6 +11,7 @@ new class extends Component { use SeoTrait; + public $country = 'de'; public string $name = ''; public ?int $country_id = null; public float $latitude = 0; @@ -18,6 +19,14 @@ class extends Component { public ?int $population = null; public ?string $population_date = null; + public function mount(): void + { + $this->country = request()->route('country', config('app.domain_country')); + $this->country_id = Country::query() + ->where('code', $this->country) + ->value('id'); + } + public function createCity(): void { $validated = $this->validate([ @@ -59,10 +68,17 @@ class extends Component {
- - + + {{ __('Select a country') }} @foreach($countries as $country) - + +
+ {{ str($country->code)->lower() }} + {{ $country->name }} +
+
@endforeach
@@ -75,6 +91,10 @@ class extends Component { + +
+ https://www.mappr.co/latitude-longitude-finder/ +
diff --git a/resources/views/livewire/venues/create.blade.php b/resources/views/livewire/venues/create.blade.php index 79bb2c5..a9df5c1 100644 --- a/resources/views/livewire/venues/create.blade.php +++ b/resources/views/livewire/venues/create.blade.php @@ -11,10 +11,16 @@ new class extends Component { use SeoTrait; + public $country = 'de'; public string $name = ''; public ?int $city_id = null; public string $street = ''; + public function mount(): void + { + $this->country = request()->route('country', config('app.domain_country')); + } + public function createVenue(): void { $validated = $this->validate([ @@ -36,7 +42,10 @@ class extends Component { public function with(): array { return [ - 'cities' => City::query()->with('country')->orderBy('name')->get(), + 'cities' => City::query() + ->with('country') + ->whereHas('country', fn($query) => $query->where('countries.code', $this->country)) + ->orderBy('name')->get(), ]; } }; ?> @@ -53,15 +62,15 @@ class extends Component {
- - + @foreach($cities as $city) - + @endforeach diff --git a/resources/views/livewire/venues/index.blade.php b/resources/views/livewire/venues/index.blade.php index 663a0af..750ac6d 100644 --- a/resources/views/livewire/venues/index.blade.php +++ b/resources/views/livewire/venues/index.blade.php @@ -27,6 +27,7 @@ class extends Component { ->when($this->search, fn($query) => $query->where('name', 'ilike', '%'.$this->search.'%'), ) + ->whereHas('city.country', fn($query) => $query->where('countries.code', $this->country)) ->orderBy('name') ->paginate(15), ];