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

CristianN's avatar

I need some help connecting a few tables form my DB

I am going to try to be as explicit as I can. I have a user that has created a client. The client has a few operations assigned to it. The relationship here is many to many. All good so far. These are operations that will need to be made by a person, live, on the job, not executed by laravel :) , just to be clear. Every operation can be executed at certain intervals ( once a week, month etc ). Normally I would just connect the operations table with an intervals table, but in the contract it can be specified that the operation that at one client will need to be performed once a month, at another client will need to be performed once every 3 months.

Any idea how I could handle this ?

0 likes
2 replies
cklmercer's avatar

So, it sounds like you have a BelongsToMany between your Client and Operation and that there should be a pivot of interval.

CristianN's avatar

Ok, but how would that look like ? And how do I store and query a relationship like: if operation 1 is assigned to client 1 and I am on client 1 details page, the interval is one month. But consider that an operation can be assigned to multiple clients, therefor the said operation will have multiple intervals assigned to it. My question was if anyone knows how I can set and retrieve the interval that was set for operation 1 when it is assigned to client 1 ?

Please or to participate in this conversation.