Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Randomize question in laravel

// If you have a quiz and want to randomize questions...

// 1. If you want to get questions in random order:
$questions = Question::inRandomOrder()->get();

// 2. If you want to also get question options in random order:
$questions = Question::with(['answers' => function($q) {
    $q->inRandomOrder();
}])->inRandomOrder()->get();
Comment

PREVIOUS NEXT
Code Example
Php :: php qatorni teskari aylantirish 
Php :: how to update all row in laravel 
Php :: get post thumbnail url 
Php :: share link in twitter php 
Php :: create custom domain in localhost xampp 
Php :: db connection postgres laravel 
Php :: foreign key nullable in laravel 
Php :: laravel cashier overwrite users table name 
Php :: Error: Call to a member function getClientOriginalName() on null in file /usr/local/var/www/murabaha_backend/app/Http/Controllers/Traits/MediaUploadingTrait.php 
Php :: how to get the values of other fields in acf validate values 
Php :: php get domain name from url 
Php :: php check internet connection 
Php :: php merge 2 arrays 
Php :: codeigniter 3 Configured database connection has cache enabled 
Php :: delete uploaded media file wp using code 
Php :: laravel with trashed 
Php :: php remove wordpress shortcodes 
Php :: types of looping directives in laravel 
Php :: guzzlehttp post json example 
Php :: laravel orwhere 
Php :: make pagination wordpress admin panel 
Php :: count in string php 
Php :: install php-fpm centos 7 
Php :: laravel query builder join 
Php :: ci count 
Php :: php goto 
Php :: truncate table laravel eloquent 
Php :: laravel relationship with for single data 
Php :: convert object to array laravel 
Php :: phpspreadsheet edit excel file 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =