Skip to content

Commit

Permalink
Streamline ease of use with relation subquery (#33180)
Browse files Browse the repository at this point in the history
Since the Relation forwards calls to the query builder object, it can be turned into a subquery just like a regular query builder object
  • Loading branch information
moshe-autoleadstar authored Jun 11, 2020
1 parent 8f738ad commit 771dfb5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Concerns\BuildsQueries;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
use Illuminate\Pagination\Paginator;
Expand Down Expand Up @@ -337,7 +338,7 @@ protected function createSub($query)
*/
protected function parseSub($query)
{
if ($query instanceof self || $query instanceof EloquentBuilder) {
if ($query instanceof self || $query instanceof EloquentBuilder || $query instanceof Relation) {
return [$query->toSql(), $query->getBindings()];
} elseif (is_string($query)) {
return [$query, []];
Expand Down Expand Up @@ -3086,6 +3087,7 @@ protected function isQueryable($value)
{
return $value instanceof self ||
$value instanceof EloquentBuilder ||
$value instanceof Relation ||
$value instanceof Closure;
}

Expand Down

0 comments on commit 771dfb5

Please sign in to comment.