I have an eloquent models as,
User : users(id, username, password, email, status)
Profile : profiles(id, user
That's where whereHas comes in handy:
whereHas
$user = User::with('Profile')->where('status', 1)->whereHas('Profile', function($q){ $q->where('gender', 'Male'); })->get();
Basically it adds the condition that the user needs to have a profile with gender = Male
gender = Male