If you want to get records based on relationship condition, you can use whereHas
method.
Here is an example:
1$allUsers = User::count() // 1000 [male/female/others]2 3$usersWithMaleGender = User::with('profile')4 ->active() // scope for where('status', 1)5 ->whereHas('profile', function ($query) {6 $query->where('gender', 'male');7 })->count(); // 650
the records of the result are all the users who has the male gender.