city = $city; $this->name = $city->name; $this->country_id = $city->country_id; $this->latitude = $city->latitude; $this->longitude = $city->longitude; $this->population = $city->population; $this->population_date = $city->population_date; } public function updateCity(): void { $validated = $this->validate([ 'name' => ['required', 'string', 'max:255', 'unique:cities,name,'.$this->city->id], 'country_id' => ['required', 'exists:countries,id'], 'latitude' => ['required', 'numeric', 'between:-90,90'], 'longitude' => ['required', 'numeric', 'between:-180,180'], 'population' => ['nullable', 'integer', 'min:0'], 'population_date' => ['nullable', 'string', 'max:255'], ]); $validated['slug'] = str($validated['name'])->slug(); $this->city->update($validated); session()->flash('status', __('City successfully updated!')); $this->redirect(route_with_country('cities.index'), navigate: true); } public function with(): array { return [ 'countries' => Country::query()->orderBy('name')->get(), ]; } }; ?>