-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Laravel Version
11.33.0
PHP Version
8.3.13
Database Driver & Version
No response
Description
Since version 11.33.0 and more precisely this commit: 8528d04, the constraints applied on MorphTo relations have changed.
For the example, let's say I have the example relation from the docs: https://laravel.com/docs/11.x/eloquent-relationships#one-to-one-polymorphic-model-structure. So I have an Image model with an imageable relation (MorphTo), pointing to a Post.
Before that commit, the foreign key constraint was correctly added to the relation query: it added a where like this:
[
"type" => "Basic"
"column" => "posts.id"
"operator" => "="
"value" => 252
"boolean" => "and"
]
Now with the latest version, the only where is:
[
"type" => "Null"
"column" => ""
"boolean" => "and"
]
This bug breaks some packages like https://github.com/kirschbaum-development/eloquent-power-joins.
Steps To Reproduce
- Create a
MorphTorelation (for exampleImage::imageable) - Call the relation:
$relation = (new Image)->imageable() - Dump the relation and watch the
wheresof the query - Change your Laravel version from
11.32.xto11.33.x
Feel free to ask if you need a proper reproduction to work on this but I think you have some test projects already covering this feature.
Thanks for your help!