public function scopeProvince($query, $province) { if (!empty($province) && $province != '0') { $nhservers = Nhserver::province($province); if ($nhservers) { $ids = array(); foreach ($nhservers as $nhserver) { $ids[] = $nhserver->id; } return $query->whereIn('location_id', $ids); } } return $query; }