I have this query:
dd(
$q2->whereHas('addresses' , function($q){
$q->getByDistance(session('se_lat'), session('se_lng'), session('se_distance'));
})
->with(['addresses' => function($q){
$q->getByDistance(session('se_lat'), session('se_lng'), session('se_distance'));
}])
->get()
);
The query does the following: Fetch all users that have addresses that fulfill a constraint (namely that its distance to some coordinates is less then some value) and an eager loading for all addresses that fulfill the above constrain.
To my surprise, the relation of addresses (that were loaded with eager loading) are empty. But since I used whereHas
with the same constrains as the eager loading, shouldn't that give me at least one address per fetched user? How is that possible that the relation is empty? Here is a screenshot:
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire