Tenant relations

Hi, everyone I'm working in a multi-tenant panel. I have a tenant that has a many-to-many with leagues. And the league has many races, so the races belong to a league. The races need to have a relationship called tenant to work as expected, is there any way I can do a "belongsToThrough" between race -> tenant? how do you usually handle this use case?
1 Reply
Fábio Roque
Fábio RoqueOP3mo ago
solved, it is possible if I use a HasOneThrough but reversing the key conventions
public function tenant(): HasOneThrough
{
return $this->hasOneThrough(
Tenant::class,
League::class,
'id',
'id',
'league_id',
'tenant_id'
);
}
public function tenant(): HasOneThrough
{
return $this->hasOneThrough(
Tenant::class,
League::class,
'id',
'id',
'league_id',
'tenant_id'
);
}

Did you find this page helpful?