See my reply here. You'll want whereHas
.
$employee_list = Employee::whereHas('manager', function ($query) {
$query->where('name', 'MANAGER');
})->with('manager');
And yes, you're correct. The callback on with
only constrains which relations are retrieved, not the base table query.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community