Skip to content

Commit

Permalink
added function to include partials
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthijs Openneer committed Oct 10, 2017
1 parent a9703d5 commit 4a8abb3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Classes/Facades/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class Location
*/
private $error = NULL;

/**
*
*/
private $excludePartials = false;

/**
* The complete response will be given here (array)
*/
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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'));
}

Expand Down

0 comments on commit 4a8abb3

Please sign in to comment.