turahe/laravel-likeable
Laravel Likeable adds likes and dislikes to any Eloquent model in minutes. Prepare your model, then use built-in methods, scopes, events, and console commands to manage reactions with clean, tested Laravel integration.
orderByLikesCount, orderByDislikesCount, and likesDiffDislikesCount (a net score, Reddit/HN-style) directly enable sort-by-top, trending modules, and digest emails without a separate ranking service. This is a scoping lever: it lets you ship a "top this week" surface without a data pipeline.liked, likesCount, collectLikers() support the UI affordances (filled vs. outlined icon, "liked by X and 42 others", liker lists) and give you the numerator for engagement-rate metrics without instrumenting a custom event stream.ModelWasLiked / ModelWasDisliked events are the hook point. Product decision: do likers get notified when someone likes their content? Do we batch? The event contract lets you defer that call without blocking the initial launch.whereLikedBy($user->id) and whereDislikedBy($user->id) give you per-user signal queries for recommendations, "because you liked…" modules, and negative-signal filtering — a cheap way to validate whether a recommender is worth investing in before committing to a real system.likeable:recount Artisan command is an admission that denormalized counts can drift, but it's also a mitigation you can point at during a launch readiness review. Product-visible counts that silently go stale are a trust bug; having a remediation command in the runbook matters.Adopt when:
likes table.Look elsewhere — or build in-house — when:
Migration note for the plan: adoption is three commands (composer require, vendor:publish, migrate) plus a trait on each model — genuinely low switching cost in both directions, which is why the reversibility argument is strong here.
For executives: "Reactions are expected in every UGC product we're planning — community, reviews, marketplace. Rather than fund a bespoke build for each surface, this is a free (MIT), drop-in component that works across all our content types at once. It's roughly a day of integration versus a sprint of internal work, and it's small enough that if we ever want to own it, we can absorb the code in an afternoon. Low cost, low lock-in, and it unblocks popularity sorting, engagement metrics, and notification hooks in one pass."
For engineering: "Composer package for Laravel 10–13, PHP 8.3+. Trait + contract on any model; polymorphic likes/dislikes table comes from a published migration. Fluent API (like, unlike, likeToggle, liked), query scopes (whereLikedBy, orderByLikesCount), events on all four transitions, and a likeable:recount command for counter reconciliation. Everything is container-bound behind contracts, so Like, LikeCounter, and LikeableService are all swappable — that's our escape hatch. 79 tests, CI across PHP 8.3–8.5 and Laravel 10–13, Larastan and Pint in the pipeline. The real caveat is maintenance: one maintainer, 9 stars, no downstream dependents. Recommendation: pin the version, fork into our org, and treat it as internal code with an upstream we occasionally sync from. That gives us the time-to-value without the bus-factor problem. Confirm before we start: soft-delete behavior on likers, our counter-drift tolerance, and whether we need rate limiting at the application layer — the package doesn't provide that and we'll own it."
How can I help you explore Laravel packages today?