laravel/framework — pull request #5577 by JamShady (2014-08-27 17:34:05+00:00)
Title: Sub-query support in from() and join()

Usage: $query->from(['foo' => $subquery])->join(['bar' => $subquery2], 'foo.id', '=', 'bar.id');

Taken from @jarredholman's work: 3ec55a146b4ec284e40e503088b15b47fff816a4

A previous PR was created (#4238) but was closed due to implementation. The implementation in this PR is more correct.