Skip to content

[12.x] Support Eloquent builders and relations as subqueries to update queries#58692

Merged
taylorotwell merged 1 commit intolaravel:12.xfrom
axlon:eloquent-subqueries
Feb 9, 2026
Merged

[12.x] Support Eloquent builders and relations as subqueries to update queries#58692
taylorotwell merged 1 commit intolaravel:12.xfrom
axlon:eloquent-subqueries

Conversation

@axlon
Copy link
Contributor

@axlon axlon commented Feb 8, 2026

This PR adds support for Eloquent\Builder and Relation in Query\Builder::update(), allowing for simpler update queries:

FooModel::where('...')->update([
-    'bar_id' => BarModel::where('...')->toBase()->select('id'),
+    'bar_id' => BarModel::where('...')->select('id'),
]);

If-condition was taken from:

if ($query instanceof self || $query instanceof EloquentBuilder || $query instanceof Relation) {

@taylorotwell taylorotwell merged commit 57eb459 into laravel:12.x Feb 9, 2026
72 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments