protected function getAliases(Builder $query)
    {
        $aliases = [];

        foreach ($query->getQuery()->columns as $column) {
            if (preg_match("~AS (\w+)~i", $column, $matches)) {
                $aliases[$query->getModel()->getTable() . '.' . $matches[1]]
                    = \DB::raw(str_replace($matches[0], '', $column));
            }
        }

        return $aliases;
    }
protected function getAliases(Builder $query)
    {
        $aliases = [];

        foreach ($query->getQuery()->columns as $column) {
            if (preg_match("~AS (\w+)~i", $column, $matches)) {
                $aliases[$query->getModel()->getTable() . '.' . $matches[1]]
                    = \DB::raw(str_replace($matches[0], '', $column));
            }
        }

        return $aliases;
    }
protected function getAliases ( Builder $ query ) { $ aliases = [ ] ; foreach ( $ query -> getQuery ( ) -> columns as $ column ) { if ( preg_match ( "~AS (\w+)~i" , $ column , $ matches ) ) { $ aliases [ $ query -> getModel ( ) -> getTable ( ) . '.' . $ matches [ 1 ] ] = \ DB :: raw ( str_replace ( $ matches [ 0 ] , '' , $ column ) ) ; } } return $ aliases ; }
Get sub queries and aliases from select statement.

@param Builder $query

@return array
Get sub queries and aliases from select statement .