How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 1911 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"))
- AngularJS - update bind ng-model input value from Jquery Code
- Laravel 5.4 - send email using Markdown Mailables
- Laravel 5 dynamic autocomplete search using select2 JS Ajax - Part 2
- Laravel 5 - Generate Captcha code and Validation example using BotDetect package
- Multiple database connections in laravel 5 Application
- How to get ip address in jquery?
- How to generate slug using str_slug() helper in Laravel 5?
- Laravel 5 - inner join with multiple conditions example using Query Builder