How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 6718 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 table name from model in Laravel 5?
- PHP - How to convert HTML file to PDF using Dompdf library?
- How to integrate jQuery Fullcalendar using Bootstrap, PHP and MySQL ?
- Laravel 5.5 Simple CMS Website example using asgardcms
- Laravel 5 - How to get route parameters in your route middleware?
- How to select concat columns with Laravel Query Builder?
- How to set git config username and email?
- How to check current password using hash check in Laravel 5.3?