How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 2191 Viewer | Category : Laravel MySql
Share this post:
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 hours difference between two dates in laravel?
- How to use Select with MySQL DATE_FORMAT() in Laravel?
- Laravel 5 manual pagination with array example
- How to add charts in Laravel 5 using Chart JS ?
- How to use where clause with mysql function in Laravel 5?
- How to change app version code in Ionic framework
- How to use elasticsearch from scratch in laravel 5?
- Laravel 5 - Google reCaptcha code and Validation example using anhskohbo/no-captcha package