public function scopeSearchByFeature($query, $name = null, $feature_class=null, $featureCodes = null)
    {
        $table = 'geonames_geonames';

        if (!isset($query->getQuery()->columns))
            $query = $query->addSelect($this->usefulScopeColumns);

        if ($name !== null)
            $query = $query->where($table . '.name', 'LIKE', $name);

        $query = $query
            ->where($table . '.feature_class', $feature_class)
            ->whereIn($table . '.feature_code', $featureCodes);

        return $query;
    }
public function scopeSearchByFeature($query, $name = null, $feature_class=null, $featureCodes = null)
    {
        $table = 'geonames_geonames';

        if (!isset($query->getQuery()->columns))
            $query = $query->addSelect($this->usefulScopeColumns);

        if ($name !== null)
            $query = $query->where($table . '.name', 'LIKE', $name);

        $query = $query
            ->where($table . '.feature_class', $feature_class)
            ->whereIn($table . '.feature_code', $featureCodes);

        return $query;
    }
public function scopeSearchByFeature ( $ query , $ name = null , $ feature_class = null , $ featureCodes = null ) { $ table = 'geonames_geonames' ; if ( ! isset ( $ query -> getQuery ( ) -> columns ) ) $ query = $ query -> addSelect ( $ this -> usefulScopeColumns ) ; if ( $ name !== null ) $ query = $ query -> where ( $ table . '.name' , 'LIKE' , $ name ) ; $ query = $ query -> where ( $ table . '.feature_class' , $ feature_class ) -> whereIn ( $ table . '.feature_code' , $ featureCodes ) ; return $ query ; }
Generic query used by scopes, but you can call it with custom feataure codes.

@param \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder $query
@param String $name
@param String $feature_class The 1 character feature class
@param array $featureCodes List of feature codes to use when returning results
@return \Illuminate\Database\Query\Builder
Generic query used by scopes but you can call it with custom feataure codes .