From 4a8abb30d36728d3030242b627938f4cb5dfe6b2 Mon Sep 17 00:00:00 2001 From: Matthijs Openneer Date: Tue, 10 Oct 2017 17:38:58 +0200 Subject: [PATCH] added function to include partials --- src/Classes/Facades/Location.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Classes/Facades/Location.php b/src/Classes/Facades/Location.php index 8f8ee84..81fe7bf 100644 --- a/src/Classes/Facades/Location.php +++ b/src/Classes/Facades/Location.php @@ -17,6 +17,11 @@ class Location */ private $error = NULL; + /** + * + */ + private $excludePartials = false; + /** * The complete response will be given here (array) */ @@ -90,6 +95,17 @@ public function countries(array $isos) return $this; } + /** + * Show result only if dataset is complete + * + * @return $this + */ + public function excludePartials() + { + $this->excludePartials = true; + return $this; + } + /** * Get the coordinates from a postal code * @@ -366,7 +382,7 @@ private function updateResponseWithResults($json) if(isset($response['results'][0])) { $this->response = $response['results'][0]; - if(@$response['results'][0]['partial_match']) { + if(@$response['results'][0]['partial_match'] && $this->excludePartials) { throw new Exception(trans('location::errors.no_results')); }