PHPackages                             languafe/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. languafe/laravel-reactions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

languafe/laravel-reactions
==========================

Add reactions to Eloquent models.

0.0.2(5mo ago)08MITPHPPHP ^8.0

Since Jul 5Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/Languafe/laravel-reactions)[ Packagist](https://packagist.org/packages/languafe/laravel-reactions)[ RSS](/packages/languafe-laravel-reactions/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (7)Used By (0)

languafe/laravel-reactions
==========================

[](#languafelaravel-reactions)

This package allows you to add reactions to eloquent models, and includes a ready-to-use blade component that renders a reaction panel with clickable buttons (requires authentication) and the count for each reaction.

Reactions are implemented as a polymorphic one-to-many relationship, and can be added to any existing model by adding the `HasReactions` trait.

The package adds a HTTP POST endpoint at `/reactions`, which is used by the reaction panel's UI in order to store reactions.

Created during "Day of Coolness" at Joubel on July 5th 2022 by Erik Langhaug where my goal was to learn about creating Laravel packages.

Usage
=====

[](#usage)

In order to make use of this package, you need an eloquent model for which you wish to enable "reactions" (which are just represented as strings and can be anything you like).

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

[](#installation)

Add the package as a composer dependency.

`composer require languafe/laravel-reactions`

Run included migration to create the `reactions` database table.

`php artisan migrate`

### Publishable items

[](#publishable-items)

> A "publishable" item from a Laravel package is something you can copy into the project directory of your own Laravel application in order to override default behavior provided by the package.

#### Configuration

[](#configuration)

To publish the config file (currently used to set which reactions are allowed) do:

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

Edit the config/reactions.php file to control which reactions are allowed.

```
