So basically something like the following should work:
DB::table('departments')
->join('users','users.dept_id','=','departments.id')
->join('absences','users.id','=','absences.user_id')
->select('departments.id','departments.deptStringName', DB::raw("COUNT(*)"))
->groupBy('departments.id','departments.deptStringName')
->get();
Note: When grouping by you should group by the unique values of the row (e.g. the identifier). If your department names are guaranteed to be unique then you can omit selecting and grouping by department.id completely.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…