jeudi 29 juin 2017

Get in Random Order Laravel

I have made a query about taking 40 question of 7215 in total with this code,

$questions = Question::where([
    'visible' => 'yes',
    'deleted' => 'no'
])
    ->inRandomOrder()
    ->take(40)
    ->get();

but in some cases I get the same question more than 1 time in this query, is there any way to take 1 question only once?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2umL3vI
via IFTTT

Aucun commentaire:

Enregistrer un commentaire