Last active
September 5, 2015 20:09
-
-
Save pomek/fd41fcfae22407210e66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Search\Criteria; | |
use Illuminate\Database\Eloquent\Builder; | |
class VenueIsInGivenLocation implements CriterionInterface | |
{ | |
/** | |
* @var string | |
*/ | |
private $location; | |
public function __construct($location) | |
{ | |
$this->location = $location; | |
} | |
/** | |
* Apply the criterion into query | |
* | |
* @param \Illuminate\Database\Eloquent\Builder | |
* @return \Illuminate\Database\Eloquent\Builder | |
*/ | |
public function apply(Builder $model) | |
{ | |
if (true === empty($this->location)) { | |
return $model; | |
} | |
return $model->where(‘venues.city’, $this->location); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment