You're correct—Filament's relation managers, when handling many-to-many pivot actions (like attach/detach), try to guess the "inverse" relationship method on the related model. By default, it expects the conventional naming: if your main resource has a relation called imprints, it will try to call $account->works() (or similar) on the Account model. When you use non-standard naming, or have multiple relations (like authors and imprints), Filament gets confused unless explicitly configured.
Solution
You need to inform Filament which inverse relationship to use. For this situation, you can use the inverseRelationship property/method on your relation manager.
Example: Specify the Inverse Relationship
In your ImprintsRelationManager, add the following property or override the method:
public static function inverseRelationship(): string
{
return 'publishedWorks'; // the name of your Account::belongsToMany(Work::class, ...)
}
Or, if you're using an older version of Filament, try:
public static $inverseRelationship = 'publishedWorks';
This tells Filament: "When doing attach/detach actions, use the publishedWorks method on the Account model to look up related works."
Final Notes
- Your relationships as written are correct.
- You only need to inform Filament about which method name to use on the related model.
- You don’t need to change your database schema or relationship definitions.
References:
If you have further customization needs (such as custom pivot data), you can check out the Filament documentation on relation managers for more options.