Skip to content

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

License

Notifications You must be signed in to change notification settings

vedatunlu/order-by-distance

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

No packages published

Languages