cybercog / laravel-love

Add Social Reactions to Laravel Eloquent Models. It lets people express how they feel about the content. Fully customizable Weighted Reaction System & Reaction Type System with Like, Dislike and any other custom emotion types. Do you react?

Home Page:https://komarev.com/sources/laravel-love

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reactant not exists.

laymont opened this issue · comments

First, sorry by me english..
I have the next problem:
public function like(Post $post) { $user = auth()->user(); $reacter = $user->viaLoveReacter(); if ($reacter->hasReactedTo($post, 'Like')) { $reacter->unreactTo($post, 'Like'); } else { $reacter->reactTo($post, 'Like'); } return back(); }
result this message:
Cog\Contracts\Love\Reactant\Exceptions\ReactantInvalid.
message: "Reactant not exists."
I followed the steps: Setup Reacterable & Setup Reactable. Help me please

Hi @laymont! This issue is the same as #168

All new reactable models registers as reactants automatically using observers, but if you are integrating package on already existing database you need to register your Reactable models as Reactants once. Just run console command:

php artisan love:register-reactants --model="App\Post"

More details in documentation: