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

sherwinmdev's avatar

Relationship with() using date field not id?

I have a bonus_periods table with a start_date and end_date columns. I have an incidents table with an incident_date column. I’d like to create bonus_periods has many incidents and vice versa where incidents.incident_date is between bonus_periods.start_date and bonus_periods.end_date.

I know how to do it with join and I can do it with nested foreach but can it be defined so I can use with()?

0 likes
0 replies

Please or to participate in this conversation.