$subTasks = SubTask::with(['task'])
->with(['users.subTaskInfos' => function ($q) {
$q->orderBy('created_at', 'desc');
$q->where('sub_task_id', '=', ?);
}])
->where('active', 1)
->get();
I want to pass Base Model SubTask id in question mark section to filter out relations data and relation collection of data. Can anyone help?
One way to achieve what you are attempting is to lazy eager load
users.subTaskInfos
- keeping the number of queries the same