laravel-mysql-spatial icon indicating copy to clipboard operation
laravel-mysql-spatial copied to clipboard

after i add data my Location field is 'null'

Open donchoborisov opened this issue 4 years ago • 3 comments

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());

}

donchoborisov avatar Nov 19 '20 21:11 donchoborisov

Same case

marwandhiaurrahman avatar Mar 17 '21 14:03 marwandhiaurrahman

same case

waadAlnwar avatar Mar 04 '22 09:03 waadAlnwar

$location = DB::raw(sprintf('POINT(%f, %f)', $request->location['latitude'], $request->location['longitude']));

I do not use the package but the MySQL function itself.

remotemerge avatar Mar 05 '23 07:03 remotemerge