NewWe open-sourced 50+ Laravel packages
Custom AI apps, agents and automation — Roundly ConsultingRoundly
All packages
Comments for Laravel

Likes & ranking

Comment reactions are powered by Likes for Laravel: the Comment model implements Likeable, so any model can like or upvote it. Actors are always passed explicitly — the package never resolves the acting user from the auth guard:

use RoundlyConsulting\Likes\Facades\Likes;

Likes::actor($user)->like($comment);
Likes::actor($user)->unlike($comment);
Likes::actor($user)->toggle($comment);   // bool: now liked?

$comment->likesCount();        // live or eager count
$comment->isLikedBy($user);    // bool
$comment->likeState($viewer);  // ['count' => 2, 'viewer_state' => ['liked' => true, 'reaction' => 'like'], 'breakdown' => ['like' => 2]]

Typed reactions

Beyond a plain like, react() keeps one active reaction per actor and switches it in place. Reaction types must be listed in the likes.reactions allowlist:

// config/likes.php → 'reactions' => ['like', 'love'],
Likes::actor($user)->as('love')->react($comment); // one active reaction, switched in place

$comment->likesCount('love');        // count for one reaction type
$comment->isLikedBy($user, 'love');  // bool

Ranking & viewer state

Rank and hydrate a whole thread through the CommentQuery builder — most-liked, trending, and single-query per-viewer like-state (no N+1):

Comments::for($post)->orderByLikesDesc()->get();      // "top comments"
Comments::for($post)->orderByTrending()->get();       // recency-weighted "hot"
Comments::for($post)->withLikedState($viewer)->get(); // each row: ->is_liked, ->liked_reaction

likeState() returns a compact payload for APIs and Blade — the total count, the viewer’s state and the per-reaction breakdown. Pass the viewer explicitly; without one it renders a guest state.

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 crypto

By 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.