vedatunlu / order-by-distance
此包可以帮助您根据给定坐标对位置模型进行排序
v1.0.0
2023-06-09 13:16 UTC
Requires
- php: >=8.0
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2024-09-21 11:22:58 UTC
README
按距离排序
此包提供了一个优雅的方式来按距离排序您的模型集合。
安装
- 使用 Composer 将包添加到您的项目中
composer require vedatunlu/order-by-distance
- 将 NearestTo 特性添加到您在 laravel 项目中要使用的模型。
重要:您的模型应在数据库中具有 'latitude' 和 'longitude' 列。
基本用法
Location::nearestTo(41.02488721726937, 29.015275681371868) ->get(); Location::where('title', $title) ->nearestTo(41.02488721726937, 29.015275681371868) ->get();
为包做贡献
我们欢迎并感谢您为包做出的贡献!贡献指南可在此找到:这里。
许可
此包是开源软件,根据 MIT 许可证 发布。