Skip to content

vedatunlu/order-by-distance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Order By Distance

This package provides an elegant way to sort your model collection by distance.

Installation

  1. Use Composer to add the package to your project:
    composer require vedatunlu/order-by-distance
  1. Add NearestTo trait to the model you want to use in your laravel project.

Important: Your model should have 'latitude' and 'longitude' columns on the database.

Basic Usage

    Location::nearestTo(41.02488721726937, 29.015275681371868)
        ->get();
        
    Location::where('title', $title)
        ->nearestTo(41.02488721726937, 29.015275681371868)
        ->get();

Contributing to the package

We welcome and appreciate your contributions to the package! The contribution guide can be found here.

License

This package is open-sourced software licensed under the MIT license.

About

An elegant way to sort your model collection with coordinates by distance

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages