is Reacted By in Eager Loading
wimil opened this issue · comments
Hi, thank you for such a beautiful package, I have a question. Is there any way to know if reactant has reacted to reacter in an Eager Loading, I have read the documentation but I can't find any way to do it.
example in Eager Loading you can do this:
https://laravel-love.readme.io/docs/eager-loading
loveReactant.reactions.type
loveReactant.reactions.reacter.reacterable
loveReactant.reactionCounters
loveReactant.reactionTotal
I would like something like this:
loveReactant.isReactedBy
I hope you can help me. thanks greetings
In eager loading you should list relationships. Method isReactedBy
is not a relation, so Eloquent can not understand what relations should be loaded eagerly.
If you only need to check isReactedBy
without N+1 issue - in this case following relationships should be enough:
$comment = Comment::query()
->with([
'loveReactant.reactions.reacter.reacterable',
'loveReactant.reactions.type',
])
->get();
@wimil I'm closing this issue. Feel free to continue conversation here if your issue isn't solved yet.