Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomek/fd41fcfae22407210e66 to your computer and use it in GitHub Desktop.
Save pomek/fd41fcfae22407210e66 to your computer and use it in GitHub Desktop.
<?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