You will need a where clause, and an orderby if you want to order it.
How to get value based on hasmany table first value?
I am having two tables batches and batch_schedules. Batches is having hasmany relationship with batch_schedules. Batches table consists of batch details and batch_schedules consists of dates & times of the schedules.
I am trying to filter batches based on batch_schedules dates. How to filter based on first date of each batches?
For Eg: Consider Batches Table having 1 row
id | Name
3 | AA1
Conside Batch_schedules having 3 rows
id | Batch_id | Date | Time
2 | 3 | 2021/04/09 | 10:00 AM
3 | 3 | 2021/04/10 | 10:00 AM
4 | 3 | 2021/04/11 | 10:00 AM
id 2 in batch_Schedules is the starting date. So I need to filter based on starting date. If my filter start date is 2021/04/08 and end date is 2021/04/11 it should display batches (id: 3).
If my filter start date is 2021/04/10 and end date is 2021/04/11 it should not display anything as there is no start date in between the filtered dates.
Please or to participate in this conversation.