PHPackages                             broqit/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. broqit/laravel-reactions

ActiveLibrary

broqit/laravel-reactions
========================

Laravel Reactions Package

0.1.14(1mo ago)3162↓25%MITPHPPHP ^8.1CI passing

Since Jul 18Pushed 1mo ago1 watchersCompare

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

READMEChangelog (7)Dependencies (10)Versions (8)Used By (0)

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

[](#laravel-reactions)

A Laravel plugin that allows users to leave reactions on posts using Livewire, similar to the functionality in `spatie/laravel-comments`.

[![Laravel Reactions Plugin](https://camo.githubusercontent.com/a5938d606864b8a0a86653b1b6cfb200a049cb6760684d2ffae088819427094a/68747470733a2f2f692e6962622e636f2f567477623668352f323032342d30372d31382d32322d33372d34392e706e67)](https://camo.githubusercontent.com/a5938d606864b8a0a86653b1b6cfb200a049cb6760684d2ffae088819427094a/68747470733a2f2f692e6962622e636f2f567477623668352f323032342d30372d31382d32322d33372d34392e706e67)

[![Tests](https://github.com/broqit/laravel-reactions/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/broqit/laravel-reactions/actions/workflows/tests.yaml?query=branch%3Amaster)[![Latest Stable Version](https://camo.githubusercontent.com/7a1df320fa12ea76fbdc498e1be2e7090fc9b536db24fb7f69c4d7d9f4cdb690/68747470733a2f2f706f7365722e707567782e6f72672f62726f7169742f6c61726176656c2d7265616374696f6e732f762f737461626c65)](https://packagist.org/packages/broqit/laravel-reactions)[![Total Downloads](https://camo.githubusercontent.com/0035b928678d4905dc2cae2c8eb4d49eff6017f656969f6d82cf0997f6c60ee2/68747470733a2f2f706f7365722e707567782e6f72672f62726f7169742f6c61726176656c2d7265616374696f6e732f646f776e6c6f616473)](https://packagist.org/packages/broqit/laravel-reactions)[![License](https://camo.githubusercontent.com/aaed2a403b41fdbb4d7c2c359a80426328d8be3b566cdb92b80e13ccdff8664b/68747470733a2f2f706f7365722e707567782e6f72672f62726f7169742f6c61726176656c2d7265616374696f6e732f6c6963656e7365)](https://packagist.org/packages/broqit/laravel-reactions)

Features
--------

[](#features)

- Flexible Reaction Types: Define multiple reaction types with custom names and icons through the configuration file.
- Model-Specific Reaction Types: Configure different reaction sets for different model types (e.g., thumbs up/down for comments, like/love for posts).
- User and Guest Reactions: Allow both authenticated users and guests to leave reactions. Configurable to restrict reactions to only users, only guests, or both.
- Customizable Reaction Limits: Set the maximum number of reactions a user or guest can leave on a single post through the configuration file.
- Dynamic Reaction Display: Utilize a Livewire component to dynamically display reaction buttons with real-time updates.
- Remove Reactions: Users and guests can remove their reactions. Configurable to set a time limit within which reactions can be removed.
- Reaction Count Display: Display the count of each reaction type for a given post.
- Total Reaction Count: Retrieve the total count of reactions for a given post.
- Grouped Reaction Count: Retrieve a count of all reactions for a given post, grouped by reaction type.
- Custom User Model: Easily configure the user model to be used for reactions.
- Easy Integration: Simple integration with any Laravel model using the HasReactions trait.

### Example configuration for reaction types:

[](#example-configuration-for-reaction-types)

```
return [
    // Default reaction types (used when no model-specific types are defined)
    'types' => [
        ['type' => 'like', 'name' => 'Like', 'icon' => '👍'],
        ['type' => 'love', 'name' => 'Love', 'icon' => '❤️'],
        ['type' => 'haha', 'name' => 'Haha', 'icon' => '😂'],
        ['type' => 'wow', 'name' => 'Wow', 'icon' => '😮'],
        ['type' => 'sad', 'name' => 'Sad', 'icon' => '😢'],
        ['type' => 'angry', 'name' => 'Angry', 'icon' => '😡'],
    ],

    // Model-specific reaction types
    // Define different reaction sets for different model classes
    'model_types' => [
        'App\Models\Post' => [
            ['type' => 'like', 'name' => 'Like', 'icon' => '👍'],
            ['type' => 'love', 'name' => 'Love', 'icon' => '❤️'],
        ],
        'App\Models\Comment' => [
            ['type' => 'thumbs_up', 'name' => 'Thumbs Up', 'icon' => '👍'],
            ['type' => 'thumbs_down', 'name' => 'Thumbs Down', 'icon' => '👎'],
        ],
    ],

    'allowed_users' => ['user', 'guest'], // Possible values: 'user', 'guest', 'both'
    'max_reactions_per_user' => 1,
    'table_name' => 'custom_reactions', // Table name
    'user_model' => null, // Default user model - null
    'removal_window_hours' => null, // Number of hours within which reactions can be removed, null means no limit
];
```

Installation
------------

[](#installation)

```
composer require broqit/laravel-reactions
```

### Database Migration

[](#database-migration)

```
php artisan vendor:publish --provider="Broqit\Laravel\Reactions\ReactionsServiceProvider" --tag=migrations
php artisan migrate
```

### Vendor publishing

[](#vendor-publishing)

```
php artisan vendor:publish --provider="Broqit\Laravel\Reactions\ReactionsServiceProvider"
```

### Style publishing

[](#style-publishing)

```
php artisan vendor:publish --provider="Broqit\Laravel\Reactions\ReactionsServiceProvider" --tag="public"
```

### Configuration

[](#configuration)

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="Broqit\Laravel\Reactions\ReactionsServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

Add the HasReactions trait to your model:

```
use Broqit\Reactions\Traits\HasReactions;

class Post extends Model
{
    use HasReactions;

    // Your model code
}
```

Add the Livewire component to your view:

```

```

> **Note**: The Tailwind styled version requires Tailwind CSS to be installed and configured in your project. No additional CSS files are needed for this variant.

Retrieve reaction counts:

```
// Get the total count of reactions for a post
$totalReactions = $post->getTotalReactionsCount();

// Get the number of 'like' reactions for a post
$likeReactions = $post->getReactionsCountByType('like');

// Get the count of all reactions for a post, grouped by type
$groupedReactions = $post->getReactionsCountGroupedByType();

// Get the available reaction types for a model (returns model-specific types if defined)
$reactionTypes = $post->getReactionTypes();
```

Model-Specific Reaction Types
-----------------------------

[](#model-specific-reaction-types)

You can configure different reaction sets for different model types. This is useful when you want different reactions for different content types (e.g., thumbs up/down for comments, like/love for posts).

To configure model-specific reactions, add them to the `model_types` array in your configuration file:

```
'model_types' => [
    'App\Models\Post' => [
        ['type' => 'like', 'name' => 'Like', 'icon' => '👍'],
        ['type' => 'love', 'name' => 'Love', 'icon' => '❤️'],
    ],
    'App\Models\Comment' => [
        ['type' => 'thumbs_up', 'name' => 'Thumbs Up', 'icon' => '👍'],
        ['type' => 'thumbs_down', 'name' => 'Thumbs Down', 'icon' => '👎'],
    ],
],
```

When a model has specific reaction types defined, the `ReactionButton` component will automatically use those types. If no model-specific types are defined, it will fall back to the default `types` configuration.

Testing
-------

[](#testing)

To run the tests, first install the development dependencies:

```
composer install --dev
```

Then run PHPUnit:

```
vendor/bin/phpunit
```

The test suite includes:

- Tests for the `HasReactions` trait, including the `getReactionTypes()` method
- Tests for the `ReactionButton` Livewire component
- Tests for model-specific reaction types configuration

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance89

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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 ~102 days

Recently: every ~59 days

Total

7

Last Release

54d ago

PHP version history (2 changes)0.1.8PHP ^8.0

0.1.12PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b0183fae593d83cd5fb3426199ba05ec2d2513b0eb40187e4793a9145256e9d?d=identicon)[broqit](/maintainers/broqit)

---

Top Contributors

[![broqit](https://avatars.githubusercontent.com/u/27624002?v=4)](https://github.com/broqit "broqit (19 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k84.2M225](/packages/laravel-horizon)[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k14.6M107](/packages/spatie-laravel-sitemap)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)

PHPackages © 2026

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