Support the ongoing development of Laravel.io →
Requests Database Eloquent
Last updated 1 year ago.
0

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();
Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.