Closed jayenne closed 3 years ago
ahh, could it be that my caling the recount isn't required ... and is actually causing the issue?
If you are creating reaction via facade you don't need to recount them. Counters will be incremented automatically. What are you trying to achieve? Is it for test reasons?
It seems that you are re-using reacterFacade from the same user. You need to instantiate a new one each time for the user.
Try something like this:
$actions = ['love','like','meh','dislike','hate'];
Post::inRandomOrder()
->where('user_id', '!=', $user->id)
->limit($count)
->each(function ($model) use ($user, $actions) {
$reacterFacade = $user->viaLoveReacter();
if ($reacterFacade->hasNotReactedTo($model)) {
shuffle($actions);
$reacterFacade->reactTo($model, $actions[0]);
}
});
@jayenne I'm closing this issue. If your question is still actual feel free to continue conversation here
thank you Anton. sorry for my late response but you nailed it perfectly. ty.
Hi, I've wrttien 3 seeders and randomly get a fail despite checking
hasNotReactedTo
I think it might be to do with the hasNotReactedTo not knowing if a job exists for that reaction. does this make sence? Thoughts on what I might be doing wrongly or ways to negate its effect and diying on seed?