Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Likes For Laravel

Likes For Laravel Laravel Package

roundly-consulting/likes-for-laravel

A lightweight Laravel package for adding like and unlike functionality to Eloquent models. Supports polymorphic relationships, toggle helpers, like counts, and eager loading so you can build reactions, favorites, or upvotes with minimal setup.

View on GitHub
Deep Wiki
Context7

Lightweight Laravel package to handle likes on entities

Frequently asked questions about Likes For Laravel
How do I install roundly-consulting/likes-for-laravel?
Install the package with Composer using composer require roundly-consulting/likes-for-laravel. Publish the included migration and run php artisan migrate to create the likes table. Then add the HasLikes trait to any Eloquent model that should support likes. The package is a Laravel library and depends on roundly/package-toolkit.
How do I make an Eloquent model likeable in Laravel?
Add the HasLikes trait to your model, such as Post or Comment. The trait exposes a simple API including like, unlike, toggleLike, and hasLiked. Likes are stored polymorphically, so the same table supports many model types.
Does this package support polymorphic likes for multiple model types?
Yes. Likes for Laravel uses a polymorphic relationship so you can like any Eloquent model type from a single likes table. That makes it suitable for reactions, favorites, upvotes, and similar features without designing extra tables. Models opt in by using the HasLikes trait.
How do I get like counts or eager-load likes in Laravel?
The package includes query helpers for filtering and eager-loading like counts, which helps avoid N+1 queries when listing models with counts. You can use these helpers alongside standard Eloquent relationships in your application queries. Check the package README for the exact helper names and examples.
Can I customize the Like model or user model?
Yes. The package is configurable, so you can swap the default Like model and the user model used by the package. This lets you adapt it to application-specific models or namespaces. Review the published configuration after installation before relying on defaults.
Which Laravel versions are supported by this package?
The package declares its Laravel framework constraint in composer.json, so check that constraint against your application's Laravel version before requiring it. The README and Packagist metadata are the source of truth for supported versions. Because this is a Composer-installed Laravel library, dependency resolution will also surface obvious version conflicts.
How do I test like and unlike behavior in Laravel?
Use Laravel's testing tools with RefreshDatabase, create a user and a likeable model, then act as the user and call like, unlike, or toggleLike. Assert hasLiked returns the expected state and that counts change correctly. You can also fake broadcast events to verify that like, unlike, and reaction-change events are dispatched.
What changed in version 1.1.2 for broadcast payloads?
In 1.1.2, actor_type and likeable_type now carry the model's class basename, such as User or Post, instead of the full PHP class name. This is a consumer-visible breaking change shipped in a patch release, although the channel name is unchanged. Listeners that compare against User::class, App\Models\User, or a morph alias will silently stop matching. Audit every consumer of the Liked, Unliked, and ReactionChanged events before upgrading.
How does a morph map affect the actor_type and likeable_type values?
With a morph map, prior payloads may have used the configured alias for actor_type and likeable_type. Version 1.1.2 replaces that alias with the class basename, so the wire value is derived from the class name again even for morph-mapped models. Listeners or clients that expect the alias will no longer match. The broadcast channel name is unaffected.
Is it safe to use a caret constraint like ^1.1.0 in production?
Not without an audit. A caret constraint allows 1.1.2, which changes broadcast payload values in a patch release, so ^1.1.0 is not a safe default if you consume these events. Pin to 1.1.1 if you need the old payload shape, or update and test all listeners and clients before upgrading. Mixed-version fleets can also publish two different payload shapes to the same channel.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo