I have a Subscriber Model
// Subscriber Model
id
user_id
subscribable_id
subscribable_type
public function user()
{
return $this->belongsTo(\'App\\U
What you're after is not hasManyThrough
, but morphedByMany
.
hasManyThrough
is useful when you have A
one-to-many B
, B
one-to-many C
, and you want to use A
to fetch many C
.
What you have is a polymorphic pivot table sitting in the middle between A
and C
.
// Topic Model
public function users()
{
return $this->morphedByMany('App\User', 'subscribable', 'pivot/subscriber_table_name');
}
Docs: https://laravel.com/docs/6.x/eloquent-relationships#many-to-many-polymorphic-relations