From 2a0c39ff174add8cfc6e8e881e01d428688aa4f9 Mon Sep 17 00:00:00 2001 From: HolgerHatGarKeineNode Date: Tue, 21 Feb 2023 20:45:59 +0100 Subject: [PATCH] convert , to . --- app/Http/Livewire/City/Form/CityForm.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/app/Http/Livewire/City/Form/CityForm.php b/app/Http/Livewire/City/Form/CityForm.php index 82007635..f68a08cf 100644 --- a/app/Http/Livewire/City/Form/CityForm.php +++ b/app/Http/Livewire/City/Form/CityForm.php @@ -21,22 +21,36 @@ class CityForm extends Component { return [ 'city.country_id' => 'required', - 'city.name' => 'required|string', - 'city.longitude' => 'required', - 'city.latitude' => 'required', + 'city.name' => 'required|string', + 'city.longitude' => 'required', + 'city.latitude' => 'required', ]; } public function mount() { - if (! $this->city) { + if (!$this->city) { $this->city = new City(); } - if (! $this->fromUrl) { + if (!$this->fromUrl) { $this->fromUrl = url()->previous(); } } + public function updatedCityLongitude($value) + { + $this->city->longitude = str($value) + ->replace(',', '.') + ->toFloat(); + } + + public function updatedCityLatitude($value) + { + $this->city->latitude = str($value) + ->replace(',', '.') + ->toFloat(); + } + public function save() { $this->validate();