after i add data my Location field is 'null'
donchoborisov opened this issue · 3 comments
donchoborisov commented
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());
}
marwandhiaurrahman commented
Same case
waadAlnwar commented
same case
remotemerge commented
$location = DB::raw(sprintf('POINT(%f, %f)', $request->location['latitude'], $request->location['longitude']));
I do not use the package but the MySQL function itself.