更新时间:2022-12-09 21:33:18
这是whereHas
派上用场的地方:
$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