Input field
<label>Longitude, Latitude <i > (Optional)</i></label>
<input type="text" value="{{old('lat_long')}}" name="lat_long" placeholder="Latitude, Longitude"
table
$table->string('lat')->nullable();
$table->string('long')->nullable();
CodePudding user response:
assume user will put lat_long
like lat,lang
so here you have separator with ,
in this case you can use explode
$latLong = request('lat_long')
try{
$latLongArray = explode(",",$latLong);
$lat = $latLongArray[0];
$long = $latLongArray[1];
}catch (\Exception $e){
throw new \Exception("Latitude and Longitude are not valid");
}
CodePudding user response:
You need to specify pattern or regex. Then use regex in laravel validation. Then create a function to explode the input and you'll get 2 inputs.
CodePudding user response:
$table->string('lat_long')->nullable();
so,you can save data of 39,107 ,when you need use,you can explode(',', "39,107")