Setup Reacterable

User model cannot directly react to the content. It should delegate this job to related Reacter model.

Code Changes

  1. Declare that model implements Cog\Contracts\Love\Reacterable\Models\Reacterable contract.

  2. Use Cog\Laravel\Love\Reacterable\Models\Traits\Reacterable trait or implement each method of the contract by yourself.

As result you will have:

<?php

namespace App;

use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableInterface;
use Cog\Laravel\Love\Reacterable\Models\Traits\Reacterable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements ReacterableInterface
{
    use Reacterable;
}

Database Changes

  1. Run set up reacterable command.
$ php artisan love:setup-reacterable --model="App\User" --nullable

📘

Remove --nullable flag if all models of this type must be reacterable:

$ php artisan love:setup-reacterable --model="App\User"

📘

Manual migration creation described in Custom Setup Migrations.

  1. Run migration.
$ php artisan migrate

Creating Reacter Models

If you are integrating package on already existing user base you need to register your Reacterable models as Reacters.

$ php artisan love:register-reacters --model="App\User"

This command will create Reacter model for each User model.