79191481

Date: 2024-11-15 07:57:40
Score: 1
Natty:
Report link

The Filament docs says it clear (not so clear for me at first :D).

When creating and listing records associated with a Tenant, Filament needs access to two Eloquent relationships for each resource - an "ownership" relationship that is defined on the resource model class, and a relationship on the tenant model class. By default, Filament will attempt to guess the names of these relationships based on standard Laravel conventions. For example, if the tenant model is App\Models\Team, it will look for a team() relationship on the resource model class. And if the resource model class is App\Models\Post, it will look for a posts() relationship on the tenant model class.

Every model that you want to be tenant aware, it has to contain a team_id, organization_id or what ever you choose_id in order for this to work.

This is needed so that the data can be scoped and filtered out for each tenant.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Kristian Vasilev