laravel-love icon indicating copy to clipboard operation
laravel-love copied to clipboard

Add query scopes to Reacterable trait

Open antonkomarev opened this issue 3 years ago • 1 comments

This MR adds whereReactedTo & whereNotReactedTo query scopes to Reacterable trait to find all Reacterable models who reacted to the Reactable model. This concept was born after discussion with @vesper8 in #181

Find users who reacted with any type of reaction to the article

$article = Article::whereKey(1)->firstOrFail();

$usersReactedToArticle = User::whereReactedTo($article);

Find users who reacted with one concerete type of reaction to the article

$article = Article::whereKey(1)->firstOrFail();
$likeReactionType = ReactionType::fromName('Like');

$usersLikedTheArticle = User::whereReactedTo($article, $likeReactionType);

This MR doesn't have tests yet and I'm not sure if we should add it to the minor release.

antonkomarev avatar Dec 06 '20 20:12 antonkomarev

Can this be merged please..

muarachmann avatar Mar 19 '21 10:03 muarachmann

@muarachmann I will try to continue work soon and try to release it in v9

antonkomarev avatar Jan 04 '23 14:01 antonkomarev

@vesper8 @muarachmann sorry for the long wait. Finally, I gave some Love to this package :)

antonkomarev avatar Jan 05 '23 12:01 antonkomarev

@antonkomarev Very nice to see you still caring about this awesome package that I'm still using in production on several projects : )

It would be awesome if you could think of a way to address https://github.com/cybercog/laravel-love/issues/192 next : )

Many thanks!! Glad to have you back! And happy new year to you!

vesper8 avatar Jan 05 '23 18:01 vesper8

Thanks @antonkomarev for this. Was much needed.

muarachmann avatar Jan 05 '23 19:01 muarachmann