Setup Reacterable
User
model cannot directly react to the content. It should delegate this job to related Reacter
model.
Code Changes
-
Declare that model implements
Cog\Contracts\Love\Reacterable\Models\Reacterable
contract. -
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\Models;
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
- Run set up reacterable command.
php artisan love:setup-reacterable --model="App\Models\User"
Add
--nullable
flag if all models of this type must NOT be reacterable:$ php artisan love:setup-reacterable --model="App\Models\User" --nullable
Manual migration creation described in Custom Setup Migrations.
- 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\Models\User"
This command will create Reacter model for each User model.
Updated 9 months ago
Next Page