📘

Prefer to use Reactant Facade instead of lower level Reactant model for the API simplicity and easier future migration process.

Get Reactable

$reactable = $reactant->getReactable();

Returns Comment, Post, User or any other model which acting as this Reactant.

Check if Reactant Reacted by Reacter

Determine if Reacter reacted to Reactant with any type of reaction.

$isReacted = $reactant->isReactedBy($reacter);

$isNotReacted = $reactant->isNotReactedBy($reacter);

Determine if Reacter reacted to Reactant with exact type of reaction.

$reactionType = ReactionType::fromName('Like');

$isReacted = $reactant->isReactedBy($reacter, $reactionType);

$isNotReacted = $reactant->isNotReactedBy($reacter, $reactionType);

Determine if Reacter reacted to Reactant with exact type of reaction and exact rate value.

$reactionType = ReactionType::fromName('Like');

$isReacted = $reactant->isReactedBy($reacter, $reactionType, 4.0);

$isNotReacted = $reactant->isNotReactedBy($reacter, $reactionType, 4.0);

Get Reactions Received by Reactant

$reactions = $reactant->getReactions();

Reaction Counters

Each Reactant has many counters (one for each reaction type) with aggregated data.

Get reaction counters of reactant

$reactionCounters = $reactant->getReactionCounters();

Get reaction counter of exact type

$reactionType = ReactionType::fromName('Like');

$reactionCounter = $reactant->getReactionCounterOfType($reactionType);

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 = $reactant->getReactionTotal();

More details read in ReactionTotal API.