Retrieve a Random Record from Your Database

LaravelPosted on

Sometimes we need to retrieve a random record from our DB. By using Eloquent we can easily do what we want:

// Get the random model
$random = Model::inRandomOrder()->first();

Need a web developer? Maybe we can help, get in touch!

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in Laravel category