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?
https://komarev.com/sources/laravel-love
MIT License
1.16k stars 72 forks source link

Does it work with factory or seeder? #208

Closed itsrafsanjani closed 2 years ago

itsrafsanjani commented 2 years ago

Normal registration and login are working fine. But when I try to use UserSeeder/UserFactory it's not working. It gets stuck after one insert into the users table.

antonkomarev commented 2 years ago

Maybe because you have not nullable love_ column in users table?

itsrafsanjani commented 2 years ago

No that's already nullable. I tried to reproduce it with a new project. But it works fine. Maybe there is some problem with observers in my project. When I run withoutEvents it works. Then I have run these commands.

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

BTW I'm using User model for both reacter and reactant.

If anyone has this problem please mention me again.

itsrafsanjani commented 2 years ago

Damn, I have found the problem. At the same time, there was 2 observer running, my own UserObserver and Reacterable/Reactable Observer. Both tried to update the User model. That's why it got stuck.

antonkomarev commented 2 years ago

Thanks for share it. Issue could be closed?

itsrafsanjani commented 2 years ago

Yeah, sure.