Get Reacterable for soft deleted (trashed) users
schwemmer opened this issue · comments
We have a bunch of soft deleted users and would like to still count their reactions (shown as "Deleted User"). The easiest way to do this is to change the relationship in the Reacter Model from this:
public function reacterable(): MorphTo
{
return $this->morphTo('reacterable', 'type', 'id', 'love_reacter_id');
}
to this:
public function reacterable(): MorphTo
{
return $this->morphTo('reacterable', 'type', 'id', 'love_reacter_id')->withTrashed();
}
However, the class is final and can not be extended. It would be great if we could somehow pass a parameter to also get reactions from soft deleted users in a future release.
See also #189
Can you call withTrashed
like in issue you provided?
$item->getReacter()->reacterable()->withTrashed()->first()
@schwemmer another one way to do this:
- Copy
\Cog\Laravel\Love\Reacter\Models\Reacter
model to your app namespace - Modify
reacterable
method to fit your needs - Override
loveReacter
method in your User (Reacterable) model (it should return custom Reacter model)
Thanks a lot @antonkomarev, the first way you mentioned above actually works great!
Can we close an issue?
Yes, thank you!