I have two model User
and Profile
in one to relationship.
I want to retrieve all user where profile.status == TRUE
using following code.
$users = User::with(['profile' => function ($query) {
$query->where('status', TRUE);
}])->get();
dd(count($users)); //50
I have 50 users and only among of them only 3 has status == TRUE
. But always it display 50.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire