PHPackages                             binafy/laravel-reactions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. binafy/laravel-reactions

ActiveLibrary[Database &amp; ORM](/categories/database)

binafy/laravel-reactions
========================

React to something in Laravel framework

v1.0.0(10mo ago)874.5k—3.2%3MITPHPPHP ^8.1CI passing

Since Sep 21Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/binafy/laravel-reactions)[ Packagist](https://packagist.org/packages/binafy/laravel-reactions)[ Docs](https://github.com/binafy/laravel-reactions)[ RSS](/packages/binafy-laravel-reactions/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (8)Dependencies (3)Versions (12)Used By (0)

Laravel Reactions
=================

[](#laravel-reactions)

[![Binafy Laravel Reactions](https://camo.githubusercontent.com/26b04bdb3cb71ba41fe04ddee9c89d6e285b120460c208618dfd8d34666cdc7f/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532305265616374696f6e732e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d62696e6166792532466c61726176656c2d7265616374696f6e73267061747465726e3d62617468726f6f6d466c6f6f72267374796c653d7374796c655f32266465736372697074696f6e3d466c657869626c652b656d6f6a692b7265616374696f6e732b666f722b4c61726176656c266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/26b04bdb3cb71ba41fe04ddee9c89d6e285b120460c208618dfd8d34666cdc7f/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532305265616374696f6e732e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d62696e6166792532466c61726176656c2d7265616374696f6e73267061747465726e3d62617468726f6f6d466c6f6f72267374796c653d7374796c655f32266465736372697074696f6e3d466c657869626c652b656d6f6a692b7265616374696f6e732b666f722b4c61726176656c266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![PHP Version Require](https://camo.githubusercontent.com/4e70d91bbe5145f676c94652e17683e2cd3b83cdfb12e0fce2f8d191b9b0bf97/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f62696e6166792f6c61726176656c2d7265616374696f6e732f706870)](https://packagist.org/packages/binafy/laravel-reactions)[![Latest Stable Version](https://camo.githubusercontent.com/5a76ddb3d7e50dbfca197ba8a0913028e8c10ae5008044c59962b14b70dc9f35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62696e6166792f6c61726176656c2d7265616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binafy/laravel-reactions)[![Total Downloads](https://camo.githubusercontent.com/968ad1b94852c868d5d27c4a28f7319f027bed29e5ef0a7c4a7e53cc1e38f061/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62696e6166792f6c61726176656c2d7265616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/binafy/laravel-reactions)[![License](https://camo.githubusercontent.com/69f4cdd1afb83ebefd2f26943bb2b5521d751473eb5f88ba3b9bb282172d39c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f62696e6166792f6c61726176656c2d7265616374696f6e73)](https://packagist.org/packages/binafy/laravel-reactions)[![Passed Tests](https://github.com/binafy/laravel-reactions/actions/workflows/tests.yml/badge.svg)](https://github.com/binafy/laravel-reactions/actions/workflows/tests.yml)[![Ask DeepWiki](https://camo.githubusercontent.com/0f5ae213ac378635adeb5d7f13cef055ad2f7d9a47b36de7b1c67dbe09f609ca/68747470733a2f2f6465657077696b692e636f6d2f62616467652e737667)](https://deepwiki.com/binafy/laravel-reactions)

Introduction
------------

[](#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
------------

[](#installation)

- `PHP >= 8.1`
- `Laravel >= 10.0`

You can install the package with Composer:

```
composer require binafy/laravel-reactions
```

Publish
-------

[](#publish)

If you want to publish a config file, you can use this command:

```
php artisan vendor:publish --tag="laravel-reactions-config"
```

If you want to publish the migrations, you can use this command:

```
php artisan vendor:publish --tag="laravel-reactions-migrations"
```

For convenience, you can use this command to publish config, migration, and ... files:

```
php artisan vendor:publish --provider="Binafy\LaravelReaction\Providers\LaravelReactionServiceProvider"
```

Usage
-----

[](#usage)

### Setting Up Your Models

[](#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

[](#user-model-setup)

```
use Binafy\LaravelReaction\Traits\Reactor;

class User extends Authenticatable
{
    use Reactor;
}
```

#### Content Model Setup

[](#content-model-setup)

```
use Binafy\LaravelReaction\Contracts\HasReaction;
use Binafy\LaravelReaction\Traits\Reactable;

class Post extends Model implements HasReaction
{
    use Reactable;
}
```

### Creating Reactions

[](#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

[](#from-user-models)

Users can react to any reactable content using the `reaction()` method from the `Reactor` trait:

```
use Binafy\LaravelReaction\Enums\LaravelReactionTypeEnum;

$user = User::find(1);
$post = Post::find(1);

// Using enum reaction types
$user->reaction(LaravelReactionTypeEnum::REACTION_ANGRY, $post);

// Using custom string reaction types
$user->reaction('love', $post);
```

#### From Reactable Models

[](#from-reactable-models)

Reactable content can also initiate reactions, which is useful when you want to handle reactions from the content's perspective:

```
$post = Post::find(1);
$user = User::find(1);

// Specify the user explicitly
$post->reaction('like', $user);

// Use the currently authenticated user
$post->reaction('like'); // Uses auth()->user()
```

### Checking Reactions

[](#checking-reactions)

You can check whether content has been reacted to by specific users using the `isReacted()` method:

```
$post = Post::find(1);
$user = User::find(1);

// Check if a specific user reacted
if ($post->isReacted($user)) {
    echo "User has reacted to this post";
}

// Check if the currently authenticated user reacted
if ($post->isReacted()) {
    echo "You have reacted to this post";
}
```

### Basic Reaction Queries

[](#basic-reaction-queries)

The `Reactable` trait provides several methods for querying reaction data:

#### Counting Reactions by Type

[](#counting-reactions-by-type)

```
$post = Post::find(1);

// Count specific reaction type
$likeCount = $post->getReactCountByType('like');
$angryCount = $post->getReactCountByType(LaravelReactionTypeEnum::REACTION_ANGRY);
```

#### Getting All Reaction Counts

[](#getting-all-reaction-counts)

```
$post = Post::find(1);

// Returns collection with type => count pairs
$reactionCounts = $post->getReactionsWithCount();
// Example result: ['like' => 5, 'love' => 3, 'angry' => 1]
```

#### Getting Reactors

[](#getting-reactors)

```
$post = Post::find(1);

// Get all users who reacted to this post
$reactors = $post->getReactors();
```

### Removing Reactions

[](#removing-reactions)

Reactions can be removed either by type or completely:

#### Remove Specific Reaction Type

[](#remove-specific-reaction-type)

```
$user = User::find(1);
$post = Post::find(1);

// Remove specific reaction type
$user->removeReaction('like', $post);

// Or from the reactable side
$post->removeReaction('like', $user);
$post->removeReaction('like'); // For authenticated user
```

#### Remove All Reactions

[](#remove-all-reactions)

```
$user = User::find(1);
$post = Post::find(1);

// Remove all reactions by the user on this post
$user->removeReactions($post);

// Or from the reactable side
$post->removeReactions($user);
$post->removeReactions(); // For authenticated user
```

### Events

[](#events)

EventDescription`StoreReactionEvent`When store new reaction`RemoveReactionEvent`When remove a reaction`RemoveAllReactionEvent`When remove all reactionsContributors
------------

[](#contributors)

Thanks to all the people who contributed. [Contributors](https://github.com/binafy/laravel-reactions/graphs/contributors).

[![](https://camo.githubusercontent.com/73cf9fbb001a5fad326fe3e28f59b0501a03a9f2dc4dae76331a434c834bfc71/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d7265616374696f6e732f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/binafy/laravel-reactions/graphs/contributors)

Security
--------

[](#security)

If you discover any security-related issues, please email `binafy23@gmail.com` instead of using the issue tracker.

Changelog
---------

[](#changelog)

The changelog can be found in the `CHANGELOG.md` file of the GitHub repository.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/binafy/laravel-reactions/blob/1.x/LICENSE) for more information.

Star History
------------

[](#star-history)

[![Star History Chart](https://camo.githubusercontent.com/f52373710057ceea429103913ace65798e4e2e8ab2055e771028342cb6a3a050/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f7376673f7265706f733d62696e6166792f6c61726176656c2d7265616374696f6e7326747970653d44617465)](https://star-history.com/#binafy/laravel-reactions&Date)

Donate
------

[](#donate)

If this package is helpful for you, you can buy a coffee for me :) ❤️

- Iranian Gateway: [https://daramet.com/milwad\_khosravi](https://daramet.com/milwad_khosravi)
- Paypal Gateway: SOON
- MetaMask Address: `0xf208a562c5a93DEf8450b656c3dbc1d0a53BDE58`

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance55

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~0 days

Total

12

Last Release

305d ago

Major Versions

v0.9.0 → v1.0.02025-07-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/56315159ed0aaddaed135c51aa64d56800b7be05ead525b35a0057d18b44b40e?d=identicon)[binafy](/maintainers/binafy)

---

Top Contributors

[![milwad-dev](https://avatars.githubusercontent.com/u/98118400?v=4)](https://github.com/milwad-dev "milwad-dev (127 commits)")

---

Tags

binafybinafy-laravel-reactionbinafy-laravel-reactionseloquentlaravellaravel-librarylaravel-packagelaravel-reactionlaravel-reactionslibrarymilwadphplaraveleloquentlikemilwadbinafylovereactionlaravel-libraryreactionslaravel-reactionsclapmilwad khosravifun developerlaravel reactions packagelaravel reactions githublaravel reaction eloquent

### Embed Badge

![Health badge](/badges/binafy-laravel-reactions/health.svg)

```
[![Health](https://phpackages.com/badges/binafy-laravel-reactions/health.svg)](https://phpackages.com/packages/binafy-laravel-reactions)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[qirolab/laravel-reactions

Implement reactions (like, dislike, love, emotion etc) on Laravel Eloquent models.

19564.6k](/packages/qirolab-laravel-reactions)[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[devdojo/laravel-reactions

3529.7k](/packages/devdojo-laravel-reactions)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
