From 976844487a83f9d1227e79ea29b954c18d000d5c Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Fri, 21 Nov 2025 13:35:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8D=20Add=20city=20creation=20modal=20?= =?UTF-8?q?and=20country=20migration=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Database/MigrateCountriesTableCommand.php | 33 ++++++ .../views/livewire/meetups/edit.blade.php | 112 +++++++++++++++++- 2 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 app/Console/Commands/Database/MigrateCountriesTableCommand.php diff --git a/app/Console/Commands/Database/MigrateCountriesTableCommand.php b/app/Console/Commands/Database/MigrateCountriesTableCommand.php new file mode 100644 index 0000000..c57dff8 --- /dev/null +++ b/app/Console/Commands/Database/MigrateCountriesTableCommand.php @@ -0,0 +1,33 @@ +output->progressStart(\WW\Countries\Models\Country::count()); + + foreach (\WW\Countries\Models\Country::all() as $country) { + Country::query() + ->updateOrCreate( + ['code' => str($country->iso_code)->lower()], + [ + 'name' => $country->name, + 'english_name' => $country->name, + ], + ); + $this->output->progressAdvance(); + } + + $this->output->progressFinish(); + $this->info('🌍 Countries migrated successfully! 🎉'); + } +} diff --git a/resources/views/livewire/meetups/edit.blade.php b/resources/views/livewire/meetups/edit.blade.php index cca46ed..77b689d 100644 --- a/resources/views/livewire/meetups/edit.blade.php +++ b/resources/views/livewire/meetups/edit.blade.php @@ -1,6 +1,7 @@ validate([ + 'newCityName' => ['required', 'string', 'max:255', 'unique:cities,name'], + 'newCityCountryId' => ['required', 'exists:countries,id'], + 'newCityLatitude' => ['required', 'numeric'], + 'newCityLongitude' => ['required', 'numeric'], + ]); + + $city = City::create([ + 'name' => $validated['newCityName'], + 'country_id' => $validated['newCityCountryId'], + 'latitude' => $validated['newCityLatitude'], + 'longitude' => $validated['newCityLongitude'], + 'slug' => str($validated['newCityName'])->slug(), + 'created_by' => auth()->id(), + ]); + + $this->city_id = $city->id; + $this->reset(['newCityName', 'newCityCountryId', 'newCityLatitude', 'newCityLongitude']); + + \Flux\Flux::modal('add-city')->close(); + } + public function mount(): void { $this->meetup->load('media'); @@ -121,7 +152,8 @@ new class extends Component { public function with(): array { return [ - 'cities' => City::orderBy('name')->get(), + 'cities' => City::query()->orderBy('name')->get(), + 'countries' => Country::query()->orderBy('countries.name')->get(), ]; } }; ?> @@ -146,9 +178,11 @@ new class extends Component { "> @if (!$logo && $meetup->getFirstMedia('logo')) - Logo + Logo @elseif($logo) - Logo + Logo @else @@ -175,14 +209,22 @@ new class extends Component { - {{ __('Stadt') }} +
+ {{ __('Stadt') }} + + + {{ __('Stadt hinzufĂŒgen') }} + + +
@foreach($cities as $city) - {{ $city->name }} + {{ $city->name }} ({{ $city->country->name }}) + @endforeach {{ __('Die nĂ€chstgrĂ¶ĂŸte Stadt oder Ort') }} @@ -325,4 +367,64 @@ new class extends Component { + + + +
+
+ {{ __('Stadt hinzufĂŒgen') }} + {{ __('FĂŒge eine neue Stadt zur Datenbank hinzu.') }} +
+ + + {{ __('Stadtname') }} * + + + + + + {{ __('Land') }} * + + @foreach($countries as $country) + +
+ {{ str($country->code)->lower() }} + {{ $country->name }} +
+
+ @endforeach +
+ +
+ +
+ + {{ __('Breitengrad') }} * + + + + + + {{ __('LĂ€ngengrad') }} * + + + +
+ +
+ + + + {{ __('Abbrechen') }} + + + {{ __('Stadt erstellen') }} +
+
+