Skip to content

Instantly share code, notes, and snippets.

@borantula
Created December 12, 2013 11:22
Show Gist options
  • Save borantula/7926528 to your computer and use it in GitHub Desktop.
Save borantula/7926528 to your computer and use it in GitHub Desktop.
Laravel 4 Eloquent Random Order. I always tend to forget it :)
<?php
//get 10 random products
$someProducts = Product::orderBy(DB::raw('RAND()'))->limit(10)->get();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment