If you are looking to filter your eloquent collection results, might I recommend this package:
https://github.com/Tucker-Eric/EloquentFilter
It allows you to make custom scopes to filter by, and is really quiet elegant and easy to use.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an EmployeeController, and an AbsenceController When i load my index view showing all the absence records for an employee i use:
$absences = Employee::find($employee_id)->absence()->get();
and pass it to my page. In addition I need to query this set of data for records that are between dates based on the records having a start and end date field (absence->start-data , absence->end_date. I also need to restrict to where the Type is H (absence->type), and the only information that i need is the total duration of H in the period X to Y from the days fields of each record (absence->duration)
Is the best approach to query the $absences by using ->where between (is this possible) and can i handle the number of criteria that i have? I did think about trying to have a function in the Absence Modal but wasn't able to work that out, specifically how to call it from the AbsenceController, but also i wasn't sure what was the best approach, as i already have the collection of records
Hoping that i have explained myself enough !! Many Thanks
Please or to participate in this conversation.