Getting error in a nested query : Exception Property [individual] does not exist on the Eloquent builder instance.
Getting this error.
$listings = Listings::with('project.city','user','project.locality')
->whereHas('project.city', function ($query) {$query->where('status', 1);})
->where ('status', '1')
->whereIn('listingtype', [$forsale, $buyers, $forrent, $lookingtorentout])
->when($request->bedrooms, function ($query) use ($request)
{$query->whereIn('bhk', [$request->bedrooms ]);})
->whereHas('user', function ($request) {$request
->whereIn('role', [$request->individual, $request->broker]);})
->latest()
->paginate(5)
->withQueryString();
I am trying to filter listings based on few filters. The error is due to filtering of listings by an individual or broker. Listings are related to 'User" and 'user' has two type of 'role'.