How to get a random record from a table in Laravel

A single line of code which allows you to retrieve a random record from a database table.

See Also: How To Change The PayPal Icon In WooCommerce

$random_quote = Quotation::orderBy(\DB::raw('RAND()'))->first();

 

0 Comments

Leave a Comment.