At the moment in one of my controllers, I have the following query:
$maintenances = DB::table("equipment_attachments")
->select(DB::raw('year(date) as year'), DB::raw("COUNT(*) as count"))
->where('attachmentCategory','Maintenance')
->orderBy(DB::raw("year(date)"))
->groupBy(DB::raw("year(date)"))
->get();
And this works alright, but I'd like to filter it down even more, and I believe I know how to do this through models, but not quite sure with using the DB functions.
What I would like to be able to do is use another table called equipment and use a field called type to filter down to those with a type of only 3.
So basically I'd like to filter down from what is above but then proceed to use the field in the table equipment_attachments to where the equipment referenced in the field equipment_attachments.unitID is equal to a equipment where the equipment.type field is equal to 3.
join()