Eloquent condition in a nested relationship not working. Currently its throwing null result. I am trying to get the leave applied on the particular date. Other is working file but when I add whereHas for attendanceAbsent.leave nested relationship, the result is null.
Attendance::with(['teacher:EMPID,EMPNAME,EMAIL,MOBILENO,SCHOOLID,DESIGNATION', 'classs:SID,CLASSNAME,SCHOOLID', 'attendanceAbsent.student', 'attendanceAbsent.leave'])->whereDate('created_at', $request->date)
->whereHas("attendanceAbsent", function($q) use($request) {
$q->where("attendance_id", "=", $request->id);
})->whereHas('attendanceAbsent.leave', function ($query) use($request) {
$query->whereDate('created_at', $request->date);
})->first();
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire