Skip to content
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

Add fetch reactions by Reacterable model #240

Merged
merged 5 commits into from
Apr 8, 2023

Conversation

antonkomarev
Copy link
Member

@antonkomarev antonkomarev commented Apr 2, 2023

Feature request appeared in issue:

This is implementation of the Solution №1 from the discussion:

High-level API (preferred)

Method \Cog\Contracts\Love\Reactant\Facades\Reactant::getReactionsBy method introduced:

public function getReactionsBy(
    Reacterable $reacterable,
): iterable;

Usage:

// Get all reactions the post received (API not changed)
$allReactionsOnPost = $post->viaLoveReactant()->getReactions();

// Get reactions the post received from the user
$userReactionsOnPost = $post->viaLoveReactant()->getReactionsBy($user);

Low-level API

Method \Cog\Contracts\Love\Reactant\Models\Reactant::getReactionsBy method introduced:

public function getReactionsBy(
    Reacter $reacter,
): iterable;

Usage:

// Get reactions the post received from the reacter user
$userReactionsOnPost = $post->getLoveReactant()->getReactionsBy($user->getLoveReacter());

@antonkomarev antonkomarev force-pushed the add-fetching-reactions-by-reacterable-model branch from 7ff5207 to aef13fa Compare April 2, 2023 19:01
@antonkomarev antonkomarev merged commit f8a28cc into master Apr 8, 2023
@antonkomarev antonkomarev deleted the add-fetching-reactions-by-reacterable-model branch April 8, 2023 15:19
@antonkomarev antonkomarev added this to the v10.0 milestone Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant