“fasih mendapatkan acak” Kode Jawaban

fasih mendapatkan acak

>>> 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();

or using the random method for collections:

User::all()->random();
User::all()->random(10); // The amount of items you wish to receive

>>> Laravel 4.2.7 - 5.1:
User::orderByRaw("RAND()")->get();

>>> Laravel 4.0 - 4.2.6:
User::orderBy(DB::raw('RAND()'))->get();

>>> Laravel 3:
User::order_by(DB::raw('RAND()'))->get();
RIFT | Web Development

Laravel mendapatkan baris acak

User::all()->random();
User::all()->random(10); // The amount of items you wish to receive
Alberto Peripolli

Jawaban yang mirip dengan “fasih mendapatkan acak”

Pertanyaan yang mirip dengan “fasih mendapatkan acak”

Lebih banyak jawaban terkait untuk “fasih mendapatkan acak” di PHP

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya