I have 4 tables with a structure and flow like this:
User
Accounts
Contacts
Orders
The relationship is as follows:
$user->hasMany(\
I created a HasManyThrough relationship with unlimited levels: Repository on GitHub
After the installation, you can use it like this:
class User extends Model {
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function orders() {
return $this->hasManyDeep(Order::class, [Account::class, Contact::class]);
}
}