muratbsts / laravel-reactable by murat

Use reactions for your Laravel model like Facebook, without pain
111
7
0
Package Data
Maintainer Username: murat
Maintainer Contact: muratbsts@gmail.com (Murat Bastas)
Package Create Date: 2017-09-09
Package Last Update: 2017-09-26
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-23 03:07:13
Package Statistics
Total Downloads: 111
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 7
Total Watchers: 0
Total Forks: 1
Total Open Issues: 4

Reactable for Laravel 5.x

Easy to use reactions, like Slack, for your Laravel models. Without the pain.

Installation

Go to your project's root folder and run the composer require command.

$ cd projects/project
$ composer require muratbsts/laravel-reactable dev-master

Then run this command for publishing migration file.

$ php artisan vendor:publish --provider="Muratbsts\Reactable\Providers\ReactableServiceProvider" --tag="migrations"

If you are on Laravel 5.5, the package will automatically be loaded into the framework.

If you are on Laravel version 5.0 - 5.4, add the service provider to config/app.php file:

<?php
...
'providers' => [
    ...
    Muratbsts\Reactable\Providers\ReactableServiceProvider::class,
    ...
],
...

Usage

Use package as like below in your models


// Post model
use Muratbsts\Reactable\Traits\Reactable;

class Post extends Model
{
    use Reactable;
    ...
    ...
}


// User model
use Muratbsts\Reactable\Traits\Reactor;

class User extends Model
{
    use Reactor;
    ...
    ...
}

And do make some reactions as like below


# Get an user's reactions
User::find(1)->reactions()->get();

# Get an post's reactions
Post::find(1)->reactions()->get();

# Make a reaction with Reactor
Post::find(1)->reaction('claps', User::find(1)); // Reaction, Reactor

# Or with Reactable
User::find(1)->reaction('claps', Post::find(1)); // Reaction, Reactable

🎉 Cheers! That's it!

License

MIT © Murat Bastas