Likes & reactions
The bundled Post implements Likeable through the HasPostReactions concern, built on likes-for-laravel. The actor is always passed explicitly — posts never reads the acting user from the auth guard:
use RoundlyConsulting\Likes\Facades\Likes;
Likes::actor($user)->like($post); // like / unlike / toggle
Likes::actor($user)->toggle($post); // returns the resulting is-liked state
Likes::actor($user)->unlike($post);
$post->isLikedBy($user); // bool
$post->likesCount(); // int (uses an eager count when hydrated)Popular and trending feeds
Ranking and per-viewer hydration compose as scopes:
Post::published()->orderByLikesDesc()->limit(10)->get(); // "popular"
Post::published()->orderByTrending()->get(); // recency-weighted
$feed = Post::published()
->withLikesCount() // hydrate likes_count
->withLikedState($viewer) // hydrate is_liked + liked_reaction (pass the viewer)
->latest()
->paginate();@foreach ($feed as $post)
{{ $post->is_liked ? '♥' : '♡' }} {{ $post->likes_count }}
@endforeachorderByLikes(), orderByLikeScore(), whereLikedBy() and whereNotLikedBy() are available too, as are the likes() relation, hasBeenLikedBy(), reactionSummary() and toLikeArray().
Compact payload
For an API or Blade, likeState() returns the count, the viewer’s state and the per-reaction breakdown:
$post->likeState($viewer);
// => ['count' => 12, 'viewer_state' => ['liked' => true, 'reaction' => 'like'], 'breakdown' => ['like' => 12]]A null viewer renders a guest state (liked false, reaction null). Typed reactions such as love or wow come from the host’s likes.reactions config — see the likes-for-laravel docs.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.