Search by

roundly-consulting / likes-for-laravel

mihaliak

Lightweight Laravel package to handle likes on entities

Package info

github.com/roundly-consulting/likes-for-laravel

pkg:composer/roundly-consulting/likes-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 16

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 17:56 UTC

This package is auto-updated.

Last update: 2026-10-03 18:05:36 UTC


README

Likes for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Likes for Laravel

Likes and reactions for any Eloquent model: any model can give likes, any model can receive them, and one polymorphic likes table records who liked what. Typed reactions, popularity and trending scopes, single-query feed hydration and reaction breakdowns come on top.

Installation

Requires PHP 8.4 and Laravel 12 or 13.

composer require roundly-consulting/likes-for-laravel
php artisan vendor:publish --tag="likes-migrations"
php artisan migrate

If your actors or likeable models have UUID/ULID keys, set LIKES_KEY_TYPE before migrating.

Usage

Let models give and receive likes:

use Illuminate\Database\Eloquent\Model;
use RoundlyConsulting\Likes\Traits\GivesLikes;
use RoundlyConsulting\Likes\Traits\HasLikes;

class Post extends Model
{
    use HasLikes;
}

class User extends Model
{
    use GivesLikes;
}

Like and read through the facade — the actor defaults to the authenticated user:

use RoundlyConsulting\Likes\Facades\Likes;

Likes::like($post);                     // true — liked now; liking again is a no-op
Likes::toggle($comment);                // the resulting state
Likes::actor($team)->like($post);       // as any other actor

Likes::for($post)->count();             // int
Likes::for($post)->likedBy($user);      // bool
Likes::for($post)->summary();           // ReactionSummary: total, counts, top, viewer's reaction

Render a feed with the viewer's state in a single query:

$posts = Post::query()
    ->withLikedState()                  // is_liked + liked_reaction for the viewer
    ->withLikesCount()                  // likes_count — still one query
    ->latest()
    ->paginate();

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/likes-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

The MIT License (MIT). Please see License File for more information.