lundi 17 décembre 2018

How to filter duplicated data of queried result?

 $users = UserDetails::select('user_details.user_id','user_details.user_nickname',
'user_media.media_url','sport_group_details.sport_group_name')
->join('users', function($join)
{
    $join->on('user_details.user_id', '=', 'users.id');

})->join('user_media',function($join){

    $join->on('user_details.user_id', '=', 'user_media.user_id');

})->join('user_to_sport_group_values',function($join){

    $join->on('user_media.user_id', '=', 'user_to_sport_group_values.user_id');

})->join('sport_group_details',function($join){

    $join->on('user_to_sport_group_values.sport_group_id', '=', 'sport_group_details.sport_group_id');

})
->selectRaw('( 6371 * acos( cos( radians(?) ) *
cos( radians( user_lat ) )
* cos( radians( user_lng ) - radians(?)
) + sin( radians(?) ) *
sin( radians(user_lat ) ) )
) AS distance', [$lattitude, $longitude, $lattitude])
->havingRaw("distance <= ?", [$max_distance])
->orderBy('distance')
->orderBy('user_details.user_nickname')->where('users.id','!=',$user_id)
->where('media_type','=','profile')
->where('sport_group_details.language_code','=', $country_code)
->get();

The User can have more than one sport_group_name So i want to get all the sport_group_name for indivisual user along with other data,But i am getting user duplicated multiples times , how can i filter that duplicated users, Any Help would be much appreciated , Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire