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

pkg:composer/stilldesign/distance-scope-trait

dev-master 2017-09-14 13:08 UTC

This package is not auto-updated.

Last update: 2025-10-26 11:02:57 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
        ...
    )

...
}