Eloquent take 25 random out of 400 first rows laravel 5.2

Posted 2 years ago by eddieace

Hi I need to make an eloquent request with top 400 rows, and select 25 random.

Right now the query looks like this. I get the latest 400 rows

$result = Model::where('status', '=', 0)
    ->orderBy('id', 'desc')

I know that I can do something like this, but then it will take all rows with status 0 but I want 25 out of the top 400.

$result = Model::where('status', '=', 0)

Please sign in or create an account to participate in this conversation.