Using Eloquent for internal querying
P粉056618053
P粉056618053 2024-04-06 16:45:50
0
1
680

Image address contains location and total number of users.

Users::with(['address'=>function($query){
    $query->where('location', 'NAXAL');
    $query->order By('total');
    }])->get();

This query will return all users, and relationships not matched by the query will be empty. I only want to extract those users who are not null on the relationship and sort accordingly.

P粉056618053
P粉056618053

reply all(1)
P粉627136450

You can use whereHas condition

Users::whereHas('address', function($query){
$query->where('location', 'NAXAL');
$query->order By('total');
})->get();
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template