Laravel 5.4 : 点击按钮后随机显示多行

Laravel 5.4 : Display mulitple rows randomly after clicking a button

我的数据库中有一个 table 个问题和一个 table question_options,我希望当用户单击播放按钮时,他会从数据库中看到一个随机问题回答它,然后按下一个按钮,另一个问题必须出现在他面前,尽管每个问题应该在 30 秒内出现。我的 tables :

Schema::create('questions', function (Blueprint $table) {
    $table->increments('id');
    $table->string('question_text');
    $table->integer('points');
    $table->integer('temps_reponse');

    $table->integer('categories_id')->unsigned();
    $table->foreign('categories_id')->references('id')->on('categories');

    $table->integer('type_id')->unsigned();
    $table->foreign('type_id')->references('id')->on('types');

    $table->timestamps();

});

Schema::create('question_options', function (Blueprint $table) {
    $table->increments('id');
    $table->string('option_one');
    $table->string('option_two');
    $table->string('option_three');
    $table->string('correcte');

    $table->integer('question_id')->unsigned()->nullable();
    $table->foreign('question_id')->references('id')->on('questions');

    $table->timestamps();

});

谁能告诉我如何解决这个问题。非常感谢任何帮助,非常感谢

$randomQuestion = DB::table('questions')
                ->inRandomOrder()
                ->get();

参见 Laravel documentation