laravel-mysql-spatial
laravel-mysql-spatial copied to clipboard
after i add data my Location field is 'null'
Hi there this is my controller after i add the data my field in the database is null can you please help me with this ?
public function updateProfile(Request $request) { $user = auth()->user();
$this->validate($request,[
'tagline'=>['required'],
'name'=>['required'],
'about'=>['required','string','min:20'],
'formatted_address' => ['required'],
'location.latitude' => ['required','numeric','min:-90','max:90'],
'location.longitude' => ['required','numeric','min:-180','max:180'],
]);
$location = new Point($request->location['latitude'],$request->location['longitude']);
$user->update([
'name' => $request->name,
'formatted_address' => $request->formatted_address,
'location' => $location,
'available_to_hire' => $request->available_to_hire,
'about' => $request->about,
'tagline' => $request->tagline,
]);
return new UserResource($user->fresh());
}
Same case
same case
$location = DB::raw(sprintf('POINT(%f, %f)', $request->location['latitude'], $request->location['longitude']));
I do not use the package but the MySQL function itself.