How to get latitude longitude from mysql in laravel 5?By Hardik Savani | March 8, 2016 | | 5846 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"))
- PHP - How to convert HTML file to PDF using Dompdf library?
- Install Sublime Text 3 in Ubuntu 14.04 using Terminal
- PHP - Input multiple tags with dynamic autocomplete example
- Codeigniter 3 - CRUD(Create, Read, Update and Delete) using JQuery Ajax, Bootstrap, Models and MySQL
- Mailgun setup with Laravel 5 example
- How to create quick apache virtual host in Ubuntu?
- Laravel 5.2 multi auth example using Auth guard from scratch
- How to get location information from ip address in Laravel ?