Download the PHP package hkp22/laravel-reactions without Composer
On this page you can find all versions of the php package hkp22/laravel-reactions. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Rated 4.00 based on 1 reviews
Informations about the package laravel-reactions
Add Reactions (like, dislike, etc.) to Eloquent Model
Laravel reactions package for implementing reactions (eg: like, dislike, love, emotion etc) on Eloquent models.
Video Tutorial
Installation
Download package into the project using Composer.
Registering package
Laravel 5.5 (or higher) uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
For Laravel 5.4 or earlier releases version include the service provider within app/config/app.php
:
Database Migration
If you want to make changes in migrations, publish them to your application first.
Run database migrations.
Config File
You can optionally publish the config file with:
Usage
Prepare Reacts (User) Model
Use Qirolab\Laravel\Reactions\Contracts\ReactsInterface
contract in model which will perform react behavior on reactable model and implement it and use Qirolab\Laravel\Reactions\Traits\Reacts
trait.
Prepare Reactable Model
Use Qirolab\Laravel\Reactions\Contracts\ReactableInterface
contract in model which will get reaction behavior and implement it and use Qirolab\Laravel\Reactions\Traits\Reactable
trait.
Available Methods
Reaction
Remove Reaction
Removing reaction of user from reactable model.
Toggle Reaction
The toggle reaction method will add a reaction to the model if the user has not reacted. If a user has already reacted, then it will replace the previous reaction with a new reaction. For example, if the user has reacted 'like' on the model. Now on toggles reaction to 'dislike' then it will remove the 'like' and stores the 'dislike' reaction.
If a user has reacted like
then on toggle reaction with like
. It will remove the reaction.
Boolean check if user reacted on model
Reaction summary on model
Get collection of users who reacted on model
Scopes
Find all articles reacted by user.
Reaction on Model
Events
On each reaction added \Qirolab\Laravel\Reactions\Events\OnReaction
event is fired.
On each reaction removed \Qirolab\Laravel\Reactions\Events\OnDeleteReaction
event is fired.
Testing
Run the tests with:
All versions of laravel-reactions with dependencies
illuminate/database Version ~5.5|~5.6|~5.7|~5.8|^6.0|^7.0|^8.0
illuminate/support Version ~5.5|~5.6|~5.7|~5.8|^6.0|^7.0|^8.0