Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afshin.asghari's avatar

Policy for BelongsToMany relations

Suppose we have a model with two "belongs to many" relations on User model,

For example a Podcast witch which has "guests" & "broadcasters" relation both leading to "User" with separate pivot tables,

According to docs, an attachAny{model} pattern is required to handle authorization on these relations, meaning one attachAnyUser on podcast policy handles both the relations mentioned above!

now I was wondering if there's any workaround for having separate methods on policy on these relations instead of just one.

0 likes
0 replies

Please or to participate in this conversation.