Reacts: Reactions for anything with one table
Add CanReact to the model that reacts and HasReactions to the model that receives reactions, run one migration, and write $user->react($post, 'love'). Reaction types come from your config, grouped per kind of content; chat messages can accept any emoji, and a post can keep one reaction per user. Unique indexes keep every reaction to one row, even when requests arrive at the same moment.
Every reaction your app needs
Two traits, one table, and a config file that lists your types.
Groups of Reaction Types
Posts offer like, love, wow and more, chat offers its own set, and a group can extend another.
Free-Form Emoji
Where a group allows it, $user->react($message, '🚀') stores exactly one emoji; text and pairs of emoji are refused.
Single or Multiple
In multiple mode a user adds several types; in single mode a new type replaces the old one in one call.
Unique by the Database
Unique indexes keep one row per reaction, and one per user in single mode, even under concurrent requests.
Counts and Listings
ReactionView::forMany() gives counts, choices and the viewer's selection for a whole page in two queries.
Policy and Events
A replaceable ReactionPolicy decides who may react, and ReactionCreated, ReactionReplaced and ReactionRemoved report every change.
A quick look
React, toggle and list reactions, with the counts and the viewer's choice in one array.
1use App\Models\Post; 2use Pharaonic\Laravel\Reacts\Support\ReactionView; 3 4Route::post('posts/{post}/react', function (Post $post) { 5 request()->user()->toggleReaction($post, request('type')); // true: added, false: removed 6 7 return back(); 8})->middleware('auth'); 9 10Route::get('posts/{post}/reactions', function (Post $post) {11 return ReactionView::for($post, request()->user())->toArray();12 // ['mode' => 'multiple', 'total' => 12, 'choices' => [...], 'used_other' => [...]]13});Reacts Questions
Quick answers about installing and using Reacts.
What is Reacts?
Let any Eloquent model react to any other with configured types such as like and love, or with any emoji where you allow it, in single or multiple mode, with counts and listings ready for Blade and JSON. It's a free, open-source Laravel package by Pharaonic.
How do I install Reacts?
Run composer require pharaonic/laravel-reacts in your project's root directory, then php artisan migrate.
What does Reacts require?
The latest release requires PHP 8.3+ and Laravel 13.
Where are the reaction types stored?
In config/pharaonic/reacts.php. The database holds only the reactions table: each row is one reaction, with a registered key such as love or a free-form emoji such as 🚀.
Can a user react more than once to the same post?
In multiple mode, the default, a user can add several different types, but never the same one twice. In single mode, per model or for the whole app, a new type replaces the previous one.
How is this different from Laravel Likes?
Laravel Likes stores one yes-or-no like per pair. Reacts stores typed reactions and emoji. Both packages can be installed side by side; they keep separate tables.
Is Reacts free to use?
Yes. Reacts is open source under the MIT license, so you can use it in personal and commercial projects.
Where can I find the Reacts documentation?
Read the Reacts documentation for setup, configuration, and usage examples.
How do I report a bug or contribute to Reacts?
Open an issue or a pull request on GitHub, ask in GitHub Discussions, or chat with us on Discord.
Ready to dig in?
Read the full documentation for installation, reaction types and groups, free-form emoji, single and multiple mode, listing reactions in Blade and JSON, policies, events, and concurrency.