---
title: "Likes for Laravel — docs | Roundly"
description: "Developer docs for Likes for Laravel: idempotent likes, typed reactions, N+1-free feeds, weighted and trending ranking, events and broadcasting."
url: https://roundly-consulting.com/open-source/docs/likes-for-laravel
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

Open source

# Likes for Laravel

Install

`composer require roundly-consulting/likes-for-laravel`

Requires: PHP ^8.4 · Laravel ^12.0|^13.0

[GitHub](https://github.com/roundly-consulting/likes-for-laravel) [Packagist](https://packagist.org/packages/roundly-consulting/likes-for-laravel) [Donate (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Patreon](https://www.patreon.com/cw/roundly)

## Overview

Native likes and reactions for Laravel. Any Eloquent model can give likes, any model can receive them, and a single polymorphic likes table records who liked what — with idempotent verbs, optional typed reactions, popularity and trending ranking, single-query feed hydration and events your app can listen to. MIT-licensed and built only on Laravel’s own components plus the Roundly package toolkit — no third-party dependencies.

### What you get

#### Any actor, any likeable

Users, teams or any Eloquent model can give likes to any other model — one polymorphic likes table records who liked what.

#### Idempotent verbs

like(), unlike() and toggleLike() return the is-liked-now state; repeats are no-ops and a re-like restores the old row.

#### Typed reactions

Opt into love, wow or your own set via an allowlist, and switch a reaction in place with a clean ReactionChanged event.

#### Feeds without N+1

withLikedState() and withLikesCount() hydrate the viewer’s state and counts for a whole page in a single query.

#### Weighted & trending ranking

Rank by a weighted reaction score or recency-boosted trending activity — portable SQL for SQLite, MySQL and PostgreSQL.

#### Events & opt-in broadcasting

Liked, Unliked and ReactionChanged fire only on real changes and can broadcast over Laravel Echo when you turn it on.

#### Testing toolkit

A recording Likes::fake(), acting-actor helpers, Pest matchers and a model factory for your own test suite.

### Documentation

#### [Installation](https://roundly-consulting.com/open-source/docs/likes-for-laravel/installation.md)

Install via Composer, then publish and run the likes migration — publish the config first for UUID or ULID keys or a custom table name.

#### [Configuration](https://roundly-consulting.com/open-source/docs/likes-for-laravel/configuration.md)

Every config key and its default — model, table, key type, reactions, actor resolver, weights, trending and broadcasting.

#### [Database schema & key types](https://roundly-consulting.com/open-source/docs/likes-for-laravel/database-schema.md)

The single polymorphic likes table, soft deletes, UUID/ULID key types and swapping in your own Like model.

#### [Models & traits](https://roundly-consulting.com/open-source/docs/likes-for-laravel/models.md)

Add HasLikes to models that can be liked and GivesLikes to actors; the relations, the Likeable contract and the Like model.

#### [The Likes facade](https://roundly-consulting.com/open-source/docs/likes-for-laravel/facade.md)

One-line likes as the signed-in user, the actor()/as() builder, the Likes::for() read handle and custom actor resolution.

#### [DI and actions](https://roundly-consulting.com/open-source/docs/likes-for-laravel/without-facade.md)

Skip the facade: inject LikeManager or call a single-purpose action with a LikeData DTO — the facade method → action map.

#### [Liking, unliking & toggling](https://roundly-consulting.com/open-source/docs/likes-for-laravel/liking.md)

Idempotent like, unlike and toggle through the Likes facade or the model trait, returning the is-liked-now state, plus bulk likeMany().

#### [Checking state & counting](https://roundly-consulting.com/open-source/docs/likes-for-laravel/checking-state.md)

Check whether an actor liked a model and count likes with Likes::has() and Likes::for() — live or from an eager-loaded count.

#### [Query scopes](https://roundly-consulting.com/open-source/docs/likes-for-laravel/query-scopes.md)

Order by like count, filter to what an actor liked or didn’t, and hydrate likes\_count — all composable, all typed.

#### [Feed hydration (no N+1)](https://roundly-consulting.com/open-source/docs/likes-for-laravel/feed-hydration.md)

withLikedState() adds is\_liked and liked\_reaction for the viewer to a whole feed page in one query — guest-safe.

#### [Weighted score & trending](https://roundly-consulting.com/open-source/docs/likes-for-laravel/ranking.md)

Rank by a weighted reaction score or recency-boosted trending activity, with portable SQL across SQLite, MySQL and PostgreSQL.

#### [Typed reactions](https://roundly-consulting.com/open-source/docs/likes-for-laravel/typed-reactions.md)

Turn plain likes into typed reactions — love, wow, laugh or your own set — guarded by a config allowlist.

#### [Switching reactions](https://roundly-consulting.com/open-source/docs/likes-for-laravel/switching-reactions.md)

react() keeps one active reaction per actor and item, switching it in place and firing only ReactionChanged.

#### [Reaction breakdown](https://roundly-consulting.com/open-source/docs/likes-for-laravel/reaction-summary.md)

Likes::for()->summary() returns totals, per-type counts, the top reaction and the viewer’s own reaction for reaction bars.

#### [What an actor liked](https://roundly-consulting.com/open-source/docs/likes-for-laravel/liked-items.md)

likedItems() and likesOf() return a real MorphToMany of the models an actor likes — eager-loadable and paginatable.

#### [Blade directive](https://roundly-consulting.com/open-source/docs/likes-for-laravel/blade-directive.md)

The @liked conditional renders the right heart state for the current or an explicit actor and reaction type.

#### [JSON API output](https://roundly-consulting.com/open-source/docs/likes-for-laravel/api-output.md)

LikeResource and toLikeArray() return the like count, the viewer’s state and the per-reaction breakdown as JSON.

#### [Events](https://roundly-consulting.com/open-source/docs/likes-for-laravel/events.md)

Liked, Unliked and ReactionChanged fire only on real changes, one event per change — plus an optional persisted counter column.

#### [Broadcasting](https://roundly-consulting.com/open-source/docs/likes-for-laravel/broadcasting.md)

Opt-in broadcasting of Liked, Unliked and ReactionChanged over Laravel Echo on likes.{morph}.{id} channels.

#### [Exceptions](https://roundly-consulting.com/open-source/docs/likes-for-laravel/exceptions.md)

InvalidReactionTypeException, NoAuthenticatedActorException and their shared LikesException base.

#### [Testing](https://roundly-consulting.com/open-source/docs/likes-for-laravel/testing.md)

Likes::fake() records every like, unlike and reaction while still writing rows — plus acting-actor helpers, Pest matchers and a Like factory.

#### [Requirements](https://roundly-consulting.com/open-source/docs/likes-for-laravel/requirements.md)

PHP 8.4+, Laravel 12 or 13, and the Roundly package toolkit — no PHP extensions or third-party packages.

## 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](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

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

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source.md)
