-
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
[5.2] Correctly load nested relationships for polymorphic relations #13737
[5.2] Correctly load nested relationships for polymorphic relations #13737
Conversation
Great work, thanks! |
Was this not merged into 5.3? |
It was? |
I will need to dig deeper then. It was working great in 5.2.34 and I just upgrade to 5.3 and it no longer seems to work. |
I still can't get this to work after upgrading to 5.3. After downgrading, the same code works fine again. Looks like 5.3 still has an issue. |
How can I use whereHas() method ?
|
If the likeable morph model could consist of a post, comment, and a third user model, and only post has the Currently this would throw an exception:
My goal would be to have something like this in the parent model: protected $with = [
'likeable.owner',
'likeable.other',
]; Where it would load the |
@joshbodine21 did you manage to get it working, I am using protected $with = [
'subject.attachments'
]; and tried directly calling it from query builder Activity::with('subject.attachments', 'causer')->latest()->get() Here is an issue which I opened spatie/laravel-activitylog#281 |
I'm currently facing the same issue that @saqueib is having. I'm on |
Firstly, this fixes a bug that was created by #13724 whereby eager loads through
protected $with
would be ignored for polymorphic relations.When writing tests for the fix, it was discovered that nested relationships are in fact never loaded for polymorphic relations. So that works too now.
This means you can now have something like