Use union for that
add to query result to anothor
Hi, I want to query something like this
$v1 = Model::where('x',1)->inRandomOrder()->limit(2)->get(); $v2 = Model::where('x',2)->inRandomOrder()->limit(4)->get(); how to add the result of v1 & v2 in one object $v= $v1+$v2;
how can i do that ? thanks
edit.., I wasn't clear. I want to choose randomly 5 or 3 or 10 users who have a higher score... my approach to solving it, first groupby the score and count them then sort them desc then do foreach on the result , then check if the higher score >= 5 then queries the 5 randomly. if less than five query them and save them in a variable, then check the next score and save them in another variable and continue the foreach until getting 5 users. finally, add them in 1 variable .. I don't how I add them in one variable...sorry my English is not good
Please or to participate in this conversation.