adamcmoore / laravel-location-validator
A Laravel validation rule to check that a lng/lat pair are within an area.
Package info
github.com/adamcmoore/laravel-location-validator
Type:package
pkg:composer/adamcmoore/laravel-location-validator
v10.1
2023-07-03 09:29 UTC
Requires
- php: ^8.1
- illuminate/console: ^10
- illuminate/database: ^10
- illuminate/filesystem: ^10
- league/geotools: ^1.1
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10
This package is auto-updated.
Last update: 2026-03-01 00:30:23 UTC
README
A Laravel validation rule to check that a lng/lat pair are within an area.
Installation
composer require adamcmoore/laravel-location-validator
Usage
use AcMoore\LocationValidator\LocationValidator; // Validate that latitude & longitude is inside an area $allowed_area = [ [48.9675969, 1.7440796], [48.4711003, 2.5268555], [48.9279131, 3.1448364], [49.3895245, 2.6119995], ]; $request->validate( [ 'latitude' => 'latitude', 'longitude' => 'longitude', ], [ 'latitude' => new LocationValidator( $request->get('longitude'), // Longitude needs to be supplied as an argument when using a Rule Object $allowed_area ) ] ); ### Todo - [ ] Add support for latitude & lognitude in same field, like spatial fields or comma seperated. - [ ] Allow multiple areas. - [ ] Add validation rule to `Validator::extend` in a service provider.