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

ricardoarg's avatar

How would you model this relationships?

Here is the tables I have (super simplified)

There are users (id / name / permission_over)

There are types (id / name)

There are categories (id / name)

There are activities (id / title / type_id / category_id)

permission_over is an enum that says 1 = permission over activities, 2 = permission over types, 3 = permission over categories

The admin will give permission to each user over one of that, so he will select N activities ID, or N types ID, or N categories ID, and then save it to that user many to many relation (one for table? polymorphic? I dont know...).

Later, I need to retrieve all the activities that the user has permission over. So if she has permission over types, I need to retrieve all the activities that has the types that she has permission over.

I hope I was sufficiently clear

0 likes
1 reply

Please or to participate in this conversation.