app/Casts/LatitudeLongitudeCast.php
use Illuminate\Contracts\Database\Eloquent\CastsAttributes; class LatitudeLongitudeCast implements CastsAttributes{ public function get($model, string $key, $value, array $attributes) : string { return str_replace(',', ', ', $value); } public function set($model, string $key, $value, array $attributes) : mixed { return str_replace(' ', '', $value); }}