Following on from my previous question, I need to get an array of a list of random ids from a model, I do:
User::all('id')->random(2)->pluck('id')->toArray()
The above works as expected, plucking 2 ids and putting them in an array:
array:2 [
0 => 63
1 => 270
]
When I switch it to just one random user though:
User::all('id')->random(1)->pluck('id')->toArray()
The entire table is returned.
array:200 [
0 => 63
1 => 270
2 => 190
...
]
My plan is to use the following to get between 1 and 10 users:
User::all('id')->random(rand(1,10))->pluck('id')->toArray()
But how can I make this work when only 1 random user is selected, why is the entire table being returned?