© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•9mo ago•
1 reply
bouly

Define multi-tenant relationship indirectly through another model

Hello,

I'm working with Filament's multi-tenancy features and I have a question about defining tenant ownership relationships.

In my app:
- A User belongs to a Team (with a team_id column).
- A Post belongs to a User (with a user_id column).
- A Post does not have a team_id column directly.

I would like Filament to treat a Post as belonging to a Team, but indirectly via its related User.
Is it possible to define the ownership relationship in this way, without adding a direct team_id column to the posts table?

I would define something like this, in the Post model:
public function team()
{
    return $this->hasOneThrough(
        Team::class,
        User::class,
        'id',
        'id',
        'user_id',
        'team_id'
    );
}
public function team()
{
    return $this->hasOneThrough(
        Team::class,
        User::class,
        'id',
        'id',
        'user_id',
        'team_id'
    );
}


Thanks for your help!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Multi-Tenancy HasManyThrough Tenant Relationship
FilamentFFilament / ❓┊help
3y ago
Child Relationship of Tenant Model
FilamentFFilament / ❓┊help
3y ago
Get user relationship for multi-tenant
FilamentFFilament / ❓┊help
13mo ago
"The model [App\Models\Team] does not have a relationship named [leads]." (Multi-tenant + Modules)
FilamentFFilament / ❓┊help
17mo ago