Example #1
0
 /**
  * Filter by city.
  *
  * @param  string $city_id
  * @return Builder
  */
 public function city($city_id = null)
 {
     if (!$city_id) {
         return;
     }
     $exploded = explode('region', $city_id);
     if (count($exploded) > 1) {
         $cities = Region::whereId($exploded[1])->first()->cities()->select('id')->get();
         return $this->builder->whereIn('city_id', $cities);
     }
     return $this->builder->where('city_id', $city_id);
 }