stilldesign / distance-scope-trait
Distance scope trait for Laravel models
Installs: 19
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 2
Open Issues: 0
Type:trait
Requires
- php: >=5.6.4
- illuminate/database: 5.4.*
This package is not auto-updated.
Last update: 2025-06-22 09:15:37 UTC
README
Distance scope trait to Laravel models
Installation
"stilldesign/distance-scope-trait": "dev-master"
Use
In the model
<?php
namespace App\Models;
use Stilldesign\DistanceScopeTrait\DistanceScopeTrait;
class ExampleModel extends Model
{
use DistanceScopeTrait;
...
}
In The controller
<?php
use App\Models\ExampleModel;
class ExampleController extends Model
{
public function index
(
...
$exampleModelItems = ExampleModel::distance($lattitude, $longitue, 100)->get();
// all items in the given coordinates, within 100 kilometers
...
)
...
}