Query/Builder.php
public function fromSub($query, $as)
    {
        [$query, $bindings] = $this->createSub($query);

        return $this->fromRaw('('.$query.') as '.$this->grammar->wrap($as), $bindings);
    }
public function fromSub($query, $as)
    {
        [$query, $bindings] = $this->createSub($query);

        return $this->fromRaw('('.$query.') as '.$this->grammar->wrap($as), $bindings);
    }
public function fromSub ( $ query , $ as ) { [ $ query , $ bindings ] = $ this -> createSub ( $ query ) ; return $ this -> fromRaw ( '(' . $ query . ') as ' . $ this -> grammar -> wrap ( $ as ) , $ bindings ) ; }
Makes "from" fetch from a subquery.

@param  \Closure|\Illuminate\Database\Query\Builder|string $query
@param  string  $as
@return \Illuminate\Database\Query\Builder|static

@throws \InvalidArgumentException
Makes from fetch from a subquery .