-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with new chaperone feature when utilizing "pluck" #52660
Comments
I'm also running into an issue with |
@samlev could you maybe look into this one? |
@driesvints sure thing. The first issue is an easy fix - just skip hydration if the child isn't a model: foreach ($models as $model) {
$model instanceof Model && $this->applyInverseRelationToModel($model, $parent);
} The second one should be relatively straightforward, too, depending on where I'll see if I can get something up early next week, of if anyone else wants a crack at it, just ping me for review. |
Because I can't help myself... It looks like |
@samlev I can confirm that I wouldn't mind making a PR, but I have no idea where to put the tests. Surely not in |
@driesvints maybe it would actually be worth pulling |
@AndrewMast / @driesvints I got some time, and got a PR together which resolves this (and some other things) |
Laravel Version
11.22
PHP Version
8.3
Database Driver & Version
No response
Description
This relates to the new feature #51582
There seems to be an issue when utilizing pluck on a model relationship. An error occurs on this line in
src/Illuminate/Database/Eloquent/Relations/Concerns/SupportsInverseRelations.php
The model being passed to applyInverseRelationToModel is an integer and not the full model.
Steps To Reproduce
in this case I am trying to query and get the "Comment" ids from a Post model
the relationship in the Post Model
the inverse relationship in the Comment Model
in theory you can fix what im trying to do by changing the line to, but that shouldnt be necessary by the end-developer
The text was updated successfully, but these errors were encountered: