Answer the question
In order to leave comments, you need to log in
The belongsTo analog of hasManyThrough?
How to create an inverse relationship for hasManyThrough?
class Manufacturer extends Model
{
public function collections()
{
return $this->hasMany('App\Collection');
}
public function colors()
{
return $this->hasManyThrough('App\Color', 'App\Collection');
}
}
class Color extends Model
{
public function manufacturer()
{
//
}
public function collection()
{
return $this->belongsTo('App\Collection');
}
}
Answer the question
In order to leave comments, you need to log in
Check out this package.
Also read the discussion on a similar issue.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question