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')) - + @elseif($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) + + + + {{ $country->name }} + + + @endforeach + + + + + + + {{ __('Breitengrad') }} * + + + + + + {{ __('LĂ€ngengrad') }} * + + + + + + + + + + {{ __('Abbrechen') }} + + + {{ __('Stadt erstellen') }} + + +