How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 5376 Viewer | Category : Laravel MySql
Whenever you need to get nearest posts from lat and long and if you are working on laravel query builder. then you can get distance easily using DB::raw(), so you can learn from following example how to get nearest value from mysql laravel.
$lat = 1;
$lon = 1;
,DB::raw("6371 * acos(cos(radians(" . $lat . "))
* cos(radians(posts.lon) - radians(" . $lon . "))
+ sin(radians(" .$lat. "))
* sin(radians(posts.lat))) AS distance"))
- How to get size of directory in MB Laravel 5?
- Solved - gulp error cannot find module laravel-elixir
- Laravel 5 Autocomplete using Bootstrap Typeahead JS Example with Demo
- Jquery highlight search text in div using highlight JS with example
- Laravel 5 - Implement Flash Messages with example
- How to create Event for Mail sending in Laravel 5.2?
- Order by using multiple columns and manually array field in Laravel?