src/Mappable.php
protected function mappedSelect(Builder $query, ArgumentBag $args)
    {
        $columns = $args->get('columns');

        foreach ($columns as $key => $column) {
            list($column, $as) = $this->extractColumnAlias($column);

            // Each mapped column will be selected appropriately. If it's alias
            // then prefix it with current table and use original field name
            // otherwise join required mapped tables and select the field.
            if ($this->hasMapping($column)) {
                $mapping = $this->getMappingForAttribute($column);

                if ($this->relationMapping($mapping)) {
                    list($target, $mapped) = $this->parseMappedColumn($mapping);

                    $table = $this->joinMapped($query, $target);
                } else {
                    list($table, $mapped) = [$this->getTable(), $mapping];
                }

                $columns[$key] = "{$table}.{$mapped}";

                if ($as !== $column) {
                    $columns[$key] .= " as {$as}";
                }

            // For non mapped columns present on this table we will simply
            // add the prefix, in order to avoid any column collisions,
            // that are likely to happen when we are joining tables.
            } elseif ($this->hasColumn($column)) {
                $columns[$key] = "{$this->getTable()}.{$column}";
            }
        }

        $args->set('columns', $columns);
    }
protected function mappedSelect(Builder $query, ArgumentBag $args)
    {
        $columns = $args->get('columns');

        foreach ($columns as $key => $column) {
            list($column, $as) = $this->extractColumnAlias($column);

            // Each mapped column will be selected appropriately. If it's alias
            // then prefix it with current table and use original field name
            // otherwise join required mapped tables and select the field.
            if ($this->hasMapping($column)) {
                $mapping = $this->getMappingForAttribute($column);

                if ($this->relationMapping($mapping)) {
                    list($target, $mapped) = $this->parseMappedColumn($mapping);

                    $table = $this->joinMapped($query, $target);
                } else {
                    list($table, $mapped) = [$this->getTable(), $mapping];
                }

                $columns[$key] = "{$table}.{$mapped}";

                if ($as !== $column) {
                    $columns[$key] .= " as {$as}";
                }

            // For non mapped columns present on this table we will simply
            // add the prefix, in order to avoid any column collisions,
            // that are likely to happen when we are joining tables.
            } elseif ($this->hasColumn($column)) {
                $columns[$key] = "{$this->getTable()}.{$column}";
            }
        }

        $args->set('columns', $columns);
    }
protected function mappedSelect ( Builder $ query , ArgumentBag $ args ) { $ columns = $ args -> get ( 'columns' ) ; foreach ( $ columns as $ key => $ column ) { list ( $ column , $ as ) = $ this -> extractColumnAlias ( $ column ) ; // Each mapped column will be selected appropriately. If it's alias // then prefix it with current table and use original field name // otherwise join required mapped tables and select the field. if ( $ this -> hasMapping ( $ column ) ) { $ mapping = $ this -> getMappingForAttribute ( $ column ) ; if ( $ this -> relationMapping ( $ mapping ) ) { list ( $ target , $ mapped ) = $ this -> parseMappedColumn ( $ mapping ) ; $ table = $ this -> joinMapped ( $ query , $ target ) ; } else { list ( $ table , $ mapped ) = [ $ this -> getTable ( ) , $ mapping ] ; } $ columns [ $ key ] = "{$table}.{$mapped}" ; if ( $ as !== $ column ) { $ columns [ $ key ] .= " as {$as}" ; } // For non mapped columns present on this table we will simply // add the prefix, in order to avoid any column collisions, // that are likely to happen when we are joining tables. } elseif ( $ this -> hasColumn ( $ column ) ) { $ columns [ $ key ] = "{$this->getTable()}.{$column}" ; } } $ args -> set ( 'columns' , $ columns ) ; }
Adjust mapped columns for select statement.

@param  \Sofa\Eloquence\Builder $query
@param  \Sofa\Hookable\Contracts\ArgumentBag $args
@return void
Adjust mapped columns for select statement .