Reactant Facade
In examples below User model is a Reacterable and Comment model is a Reactable.
$reactantFacade = $comment->viaLoveReactant();
Check if Reactable Reacted by Reacterable
Determine if Comment reacted by User with any type of reaction.
$isReacted = $reactantFacade->isReactedBy($user);
$isNotReacted = $reactantFacade->isNotReactedBy($user);
Determine if Comment reacted by User with exact type of reaction.
$isReacted = $reactantFacade->isReactedBy($user, 'Like');
$isNotReacted = $reactantFacade->isNotReactedBy($user, 'Like');
Determine if Comment reacted by User with exact type of reaction and exact rate value.
$isReacted = $reactantFacade->isReactedBy($user, 'Like', 4.0);
$isNotReacted = $reactantFacade->isNotReactedBy($user, 'Like', 4.0);
Reaction Counters
Each Reactant has many counters (one for each reaction type) with aggregated data.
Get reaction counters of reactant
$reactionCounters = $reactantFacade->getReactionCounters();
Get reaction counter of exact type
$reactionCounter = $reactantFacade->getReactionCounterOfType('Like');
More details read in ReactionCounter API.
Reaction Totals
Each Reactant has one total with aggregated data. Total is sum of counters of all reaction types.
Get reaction total of reactant
$reactionTotal = $reactantFacade->getReactionTotal();
Updated about 6 years ago
