How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 4444 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"))
- Laravel 5 query builder where exists example
- Laravel 5 - Custom Helper Facade Class Example from scratch
- Laravel 5 - How to convert file(image, audio, video) extension using CloudConvert?
- PHP - Behance API tutorial with example and demo
- Laravel 5 - user prevent common passwords using laravel-password package
- Angular $scope.form value undefined on submit in ionic framework.
- Jquery Select2 - Select box with search example code
- How to get soft deleted records in Laravel 5?