I have the following models:
Product
BaseProduct
BaseCode
Series
Each of them is something of a separate entity, but they\'re related.
I created a HasManyThrough
relationship with unlimited levels: Repository on GitHub
After the installation, you can use it like this:
class Series extends Model {
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function products() {
return $this->hasManyDeep(Product::class,
[BaseCode::class, BaseProduct::class],
['SeriesId', 'BaseCodeId', 'BaseProductId']
);
}
}