I have made a laravel query which gets all the data but does not use the where clause for $startdate.
$user->studentGroups()->with([
'GroupTasks' => function ($queryTwo) use ($startdate)
{ return $queryTwo->where('start_date', '>', $startdate); } // THIS LINE IS NOT WORKING!!
])->with(['GroupTasks.prgressList' => function ($queryThree) use ($student_id)
{ return $queryThree->where('progress_student_task_users.mis_id', $student_id); },
'GroupTasks.studentViews' => function ($queryfour) use ($student_id){ return $queryfour->where('student_task_user_vieweds.mis_id', $student_id)->latest(); },
])->get();
Without the start date working it just gets all the data which is not really the idea. Any idea how to fix?