Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to get an random data from a table using eloquent

Laravel >= 5.2:

User::inRandomOrder()->get();
or to get the specific number of records

// 5 indicates the number of records
User::inRandomOrder()->limit(5)->get();
// get one random record
User::inRandomOrder()->first();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #random #data #table #eloquent
ADD COMMENT
Topic
Name
8+6 =