public function scopeAdmin1($query)
    {
        $table = 'geonames_geonames';

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

        $query = $query
            ->leftJoin('geonames_admin1_codes as admin1', 'admin1.code', '=',
                DB::raw('CONCAT_WS(\'.\',' .
                    $table . '.country_code,' .
                    $table . '.admin1_code)')
            )
            ->addSelect(
                'admin1.geoname_id as admin1_geoname_id',
                'admin1.name as admin1_name'
            );

        return $query;
    }
public function scopeAdmin1($query)
    {
        $table = 'geonames_geonames';

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

        $query = $query
            ->leftJoin('geonames_admin1_codes as admin1', 'admin1.code', '=',
                DB::raw('CONCAT_WS(\'.\',' .
                    $table . '.country_code,' .
                    $table . '.admin1_code)')
            )
            ->addSelect(
                'admin1.geoname_id as admin1_geoname_id',
                'admin1.name as admin1_name'
            );

        return $query;
    }
public function scopeAdmin1 ( $ query ) { $ table = 'geonames_geonames' ; if ( ! isset ( $ query -> getQuery ( ) -> columns ) ) $ query = $ query -> addSelect ( $ this -> usefulScopeColumns ) ; $ query = $ query -> leftJoin ( 'geonames_admin1_codes as admin1' , 'admin1.code' , '=' , DB :: raw ( 'CONCAT_WS(\'.\',' . $ table . '.country_code,' . $ table . '.admin1_code)' ) ) -> addSelect ( 'admin1.geoname_id as admin1_geoname_id' , 'admin1.name as admin1_name' ) ; return $ query ; }
Return admin1 information in result

@param \Illuminate\Database\Query\Builder $query
@return \Illuminate\Database\Query\Builder
Return admin1 information in result