cybercog / laravel-love

Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?

Home Page:https://komarev.com/sources/laravel-love

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to include ALL the reaction for a given piece of content?

sinisimattia opened this issue · comments

Hello and thank you for the amazing package.

I've run into an "issue" with my application and I couldn't find anything online so I'd like to ask you if there's a way to get all the reaction counters, even if some reactions are 0.

If this method already exist then it would be great, or maybe you cloud suggest a way to do it with Laravel's built in eager-loading?

I wouldn't wanto to slow down my application with my own implementation so I'm asking for help.

Thanks in advance!

Hi @sinisimattia! It is a good question. You can join reactions counters and totals using joins. It will add counter with 0 value if there is no reactions. But I'm afraid I haven't added this feature to the Reactant Facade.

More details in documentation: https://laravel-love.readme.io/docs/reactable-ordering#order-by-total-count-of-reactions
More usage examples in ReactableTests: https://github.com/cybercog/laravel-love/blob/a7efe538c86c077be838639bae6d4300bb975043/tests/Unit/Reactable/Models/Traits/ReactableTest.php

Oh ok, thank you very much. 😁