src/RetrievesIntermediateTables.php
public function withPivot($table, array $columns = ['*'], $class = Pivot::class, $accessor = null)
    {
        if ($columns === ['*']) {
            $columns = $this->query->getConnection()->getSchemaBuilder()->getColumnListing($table);
        }

        $accessor = $accessor ?: $table;

        if (isset($this->intermediateTables[$accessor])) {
            $columns = array_merge($columns, $this->intermediateTables[$accessor]['columns']);
        }

        $this->intermediateTables[$accessor] = compact('table', 'columns', 'class');

        return $this;
    }
public function withPivot($table, array $columns = ['*'], $class = Pivot::class, $accessor = null)
    {
        if ($columns === ['*']) {
            $columns = $this->query->getConnection()->getSchemaBuilder()->getColumnListing($table);
        }

        $accessor = $accessor ?: $table;

        if (isset($this->intermediateTables[$accessor])) {
            $columns = array_merge($columns, $this->intermediateTables[$accessor]['columns']);
        }

        $this->intermediateTables[$accessor] = compact('table', 'columns', 'class');

        return $this;
    }
public function withPivot ( $ table , array $ columns = [ '*' ] , $ class = Pivot :: class , $ accessor = null ) { if ( $ columns === [ '*' ] ) { $ columns = $ this -> query -> getConnection ( ) -> getSchemaBuilder ( ) -> getColumnListing ( $ table ) ; } $ accessor = $ accessor ? : $ table ; if ( isset ( $ this -> intermediateTables [ $ accessor ] ) ) { $ columns = array_merge ( $ columns , $ this -> intermediateTables [ $ accessor ] [ 'columns' ] ) ; } $ this -> intermediateTables [ $ accessor ] = compact ( 'table' , 'columns' , 'class' ) ; return $ this ; }
Set the columns on a pivot table to retrieve.

@param  string  $table
@param  array  $columns
@param  string  $class
@param  string|null  $accessor
@return $this
Set the columns on a pivot table to retrieve .