Where clause inside whereHas being ignored in Eloquent
问题 Im trying to make a query using whereHas with eloquent. The query is like this: $projects = Project::whereHas('investments', function($q) { $q->where('status','=','paid'); }) ->with('investments') ->get(); Im using Laravel 5.2 using a Postgres driver. The Project model is: public function investments() { return $this->hasMany('App\Investment'); } The investments model has: public function project() { return $this->belongsTo('App\Project'); } The projects table has fields id,fields... The