You're doing a bit wrong with the whereHas(). It cannot eager load. It's simply to constrain the relation "tasks" in this case. And also according to your model tasks has a relation method named "tasks".
try this:
$user = User::whereHas('tasks', function($q)
{
$q->where('status', '!=', 'closed');
})
->with('tasks', 'tasks.clients')
->where('id', Auth::user()->id)
->first();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community