Looking to hire Laravel developers? Try LaraJobs

laravel-reacts maintained by pharaonic

Description
Polymorphic emoji reactions for Laravel Eloquent models, with registered types, grouped catalogs, single or multiple mode, and database-enforced uniqueness.
Last update
2026/11/14 10:02 (dev-develop)
License
Links
Downloads
0

Comments
comments powered by Disqus

Installation

composer require pharaonic/laravel-reacts
php artisan migrate

The service provider is registered automatically, and migrate creates the reactions table. Publish the configuration to define your own reaction types and groups:

php artisan vendor:publish --tag=reacts-config

Usage

Add CanReact to the model that reacts and HasReactions to the model that receives reactions:

use Illuminate\Foundation\Auth\User as Authenticatable;
use Pharaonic\Laravel\Reacts\Concerns\CanReact;

class User extends Authenticatable
{
    use CanReact;
}
use Illuminate\Database\Eloquent\Model;
use Pharaonic\Laravel\Reacts\Concerns\HasReactions;

class Post extends Model
{
    use HasReactions;
}
use Pharaonic\Laravel\Reacts\Support\ReactionView;

$user->react($post, 'like');            // true: added
$user->react($post, 'love');            // true: a second type (multiple mode, the default)
$user->react($post, 'love');            // false: already there
$user->toggleReaction($post, 'like');   // false: removed
$user->hasReacted($post, 'love');       // true
$user->react($chatMessage, '🚀');        // true: in a group that allows free-form emoji

$post->reactionCounts();                // ['love' => 1]
ReactionView::for($post, $user)->toArray(); // choices, counts and the viewer's selection, for Blade or JSON

Documentation

Full documentation: Laravel Reacts Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.