Download the PHP package binafy/laravel-reactions without Composer
On this page you can find all versions of the php package binafy/laravel-reactions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download binafy/laravel-reactions
More information about binafy/laravel-reactions
Files in binafy/laravel-reactions
Package laravel-reactions
Short Description Laravel Reactions is a simple and flexible package that allows you to add reaction functionality to any Eloquent model
License MIT
Homepage https://github.com/binafy/laravel-reactions
Informations about the package laravel-reactions
Laravel Reactions
Introduction
Laravel Reactions is a simple and flexible package that enables you to add reaction functionality (such as 👍, ❤️, 😂, etc.) to any Eloquent model in your Laravel application. Whether you're building a social network, blog, or forum, this package makes it easy for users to express themselves through customizable reactions.
🔧 Features:
- Add reactions to any model (e.g., posts, comments, messages)
- Multiple reaction types (like, love, laugh, etc.)
- Easy API for adding/removing reactions
- Track who reacted and how
- Eloquent relationships for seamless integration
- Built-in support for custom reaction types
- Lightweight and easy to customize
Installation
You can install the package with Composer:
Publish
If you want to publish a config file, you can use this command:
If you want to publish the migrations, you can use this command:
For convenience, you can use this command to publish config, migration, and ... files:
Usage
Setting Up Your Models
Before using reactions, your models need the appropriate traits. User models require the Reactor trait to create reactions, while content models require the Reactable trait to receive reactions.
User Model Setup
Content Model Setup
Creating Reactions
There are multiple ways to create reactions depending on your application's needs. You can create reactions from the user perspective or from the reactable content perspective.
From User Models
Users can react to any reactable content using the reaction() method from the Reactor trait:
From Reactable Models
Reactable content can also initiate reactions, which is useful when you want to handle reactions from the content's perspective:
Checking Reactions
You can check whether content has been reacted to by specific users using the isReacted() method:
Basic Reaction Queries
The Reactable trait provides several methods for querying reaction data:
Counting Reactions by Type
Getting All Reaction Counts
Getting Reactors
Removing Reactions
Reactions can be removed either by type or completely:
Remove Specific Reaction Type
Remove All Reactions
Events
| Event | Description |
|---|---|
StoreReactionEvent |
When store new reaction |
RemoveReactionEvent |
When remove a reaction |
RemoveAllReactionEvent |
When remove all reactions |
Contributors
Thanks to all the people who contributed. Contributors.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Changelog
The changelog can be found in the CHANGELOG.md file of the GitHub repository.
License
The MIT License (MIT). Please see License File for more information.
Star History
Donate
If this package is helpful for you, you can buy a coffee for me :) ❤️
- Iranian Gateway: https://daramet.com/milwad_khosravi
- Paypal Gateway: SOON
- MetaMask Address:
0xf208a562c5a93DEf8450b656c3dbc1d0a53BDE58