在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):malhal/Laravel-Geographical开源软件地址(OpenSource Url):https://github.com/malhal/Laravel-Geographical开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Laravel GeographicalEasily add longitude and latitude columns to your records and use inherited functionality for calculating distances. First either update your database or add this to a migration for each model: $table->double('longitude');
$table->double('latitude'); Finally in your model use: use Geographical; 1. DistanceFind the distance to all the entries in your table from a particular location. $query = Model::distance($latitude, $longitude);
$asc = $query->orderBy('distance', 'ASC')->get(); 2. GeofenceFind all the entries in your table inside a circular geo-fence. $query = Model::geofence($latitude, $longitude, $inner_radius, $outer_radius);
$all = $query->get(); UnitsThe default unit of distance is miles. You can change it to kilometers by putting this in your model protected static $kilometers = true; Notes
InstallationPHP 5.6.4+ and Laravel 5+ are required. To get the latest version of Laravel Geographical, simply require the project using Composer: $ composer require malhal/laravel-geographical |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论