How to get data as per Sending preference - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Tuesday, December 14, 2021

How to get data as per Sending preference

I want to fetch user who has most points. I've two tables users and points.

$top10pp = Points::orderBy('points', 'DESC')->limit(10)->get('ppid');

I'm getting user id as per there points correctly by above query. Then I'm fetching the users by their user id that im getting in $top10pp variable.

$psname = $this->getpp($top10pp);

I'm calling a function to return the user. Till this everything is ok.

public function getpp($ppid)
{
    $data = User::whereIn('id', $ppid)->get();
    return $data;
}

and after calling this function im not getting data as i've sent this function arranging data in ascending order as per user id. If i've send 5,2,6,10,1 it returns me information of 1 user first then 2,5,6 then 10 like this. But i want data as per im sending it.



source https://stackoverflow.com/questions/70338987/how-to-get-data-as-per-sending-preference

No comments:

Post a Comment