Download the PHP package cslant/laravel-like without Composer
On this page you can find all versions of the php package cslant/laravel-like. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cslant/laravel-like
More information about cslant/laravel-like
Files in cslant/laravel-like
Package laravel-like
Short Description A package providing like, dislike, love and unlike interaction features for Laravel applications.
License MIT
Homepage https://github.com/cslant/laravel-like
Informations about the package laravel-like
laravel-like
The interaction for User 👍 like, 👎 dislike, and love ❤️ features for Laravel Application.
📝 Introduction
This package provides an interaction way to add like 👍, dislike 👎, and love ❤️ features to your Laravel application.
It is easy to use and can be customized to fit your needs.
📋 Requirements
- PHP ^8.2
- Laravel ^11.0|^12.0|^13.0
📖 Official Documentation
The detailed documentation is in the Laravel Like Package - Official documentation.
🔧 Installation
You can install the package via Composer:
Configuration and Migrations
You can publish all the necessary configuration and migration files by running the following command:
After the configuration file has been published, you can run the migration:
🛠️ Usage
Facade
Like and Love both proxy the same LikeManager singleton, kept as separate facades so each stays focused on its own domain (like/dislike vs. love):
By default the acting user is resolved via auth()->id(). Pass an explicit user id as the second argument to override:
Model traits
Add HasLike to an interactable model:
Then:
Use HasLove (and/or UserHasInteraction on the user model) for love-only surfaces.
⚡ Performance
All counts are a single COUNT query, and predicates use EXISTS, so a single call never causes an N+1. But calling likesCount() or isLiked() in a loop over a list still does — use the batch APIs instead:
Or, when you're already building the query, prefer Eloquent's own withCount():
Querying a user's liked models performs one query per distinct model type (a bounded cost inherent to polymorphic relations):
When listing interactions, eager-load related models to avoid per-row queries:
Read-heavy counts can also be cached — set cache.enabled to true in config/like.php and the package invalidates it automatically on every write. See the Performance docs for the full picture.
🤖 AI agent skill
This repo ships a Claude Code skill summarizing safe usage patterns (the batch APIs, the N+1 pitfalls, the facade split). If your project uses this package and you use Claude Code, copy .claude/skills/laravel-like/ from this repo into your own project's .claude/skills/ directory so your AI assistant applies it automatically.
📄 License
The MIT License (MIT). Please see License File for more information.
🙏 Acknowledgement
This package is inspired by the laravel-like package by overtrue. I have added some additional features and improvements to the package.
All versions of laravel-like with dependencies
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0