I have read this a couple of times and still don't understand what you are attempting to achieve; why are you eager-loading profile twice? The whereHas method takes a Closure; did you mean to use the has method instead?
Jun 6, 2018
3
Level 1
Need a little help with a query involving withCount
Doing a search query right now and I am trying to get the count of the hires of the profile that owns the project.
$query = Project::with('profile');
$query->with(['profile' => function ($q) {
$q->withCount('hires', function ($qr) {
$qr->where('hires_count', '=', '0');
});
the hires function belonging to the profile
public function hires()
{
return $this->projects()->where('status', '<>', 'available')->whereHas('bids');
}
and I am getting this error:
"mb_strpos() expects parameter 1 to be string, object given"
Please or to participate in this conversation.