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

NotAssignedToReactable exception when trying to access deleted item

Marchiuzzz opened this issue · comments

Hi, I have noticed an issue when trying to access the reactable object from a reaction like so
$item->getReactant()->getReactable() for a deleted item (an object that uses soft deletes)
I just get thrown NotAssignedToReactable exception, shouldn't it handle this on it's own?

You cannot get soft deleted Reactable model from the Reactant using getReactable method at this moment, but you can do it this way:

$item->getReactant()->reactable()->withTrashed()->first()

Thanks for the workaround! Though I already figured another way to tackle this, with try-catch, if trying to get reactable throws an error, I know that item was deleted.