Skip to content

adamcmoore/laravel-location-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Location Validator

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.

About

A Laravel validation rule to check that a lng/lat pair are within an area.

Resources

License

GPL-3.0, AGPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
AGPL-3.0
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages