更新时间:2022-12-09 21:54:56
这就是 whereHas
派上用场的地方:
That's where whereHas
comes in handy:
$user = User::with('Profile')->where('status', 1)->whereHas('Profile', function($q){
$q->where('gender', 'Male');
})->get();
基本上它增加了用户需要具有gender = Male
Basically it adds the condition that the user needs to have a profile with gender = Male