:::

5-5 /database/factories/TopicFactory.php

<?php

use Faker\Generator as Faker;

$factory->define(App\Topic::class, function (Faker $faker) {

    $items = [1, 2, 3, 4];
    shuffle($items);

    $random_date = $faker->dateTimeBetween('-3 days', '+3 days');

    $num1 = rand(1, 9);
    $num2 = rand(1, 9);

    return [
        'topic'           => "$num1 x $num2 = ?",
        'opt' . $items[0] => $num1 * $num2,
        'opt' . $items[1] => $num1 + $num2,
        'opt' . $items[2] => $num1 . $num2,
        'opt' . $items[3] => $num2 . $num1,
        'ans'             => $items[0],
        'created_at'      => $random_date,
        'updated_at'      => $random_date,
    ];
});

 


:::

書籍目錄

展開 | 闔起

https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D41%26tbdsn%3D1320

計數器

今天: 1124112411241124
昨天: 4125412541254125
總計: 5553134555313455531345553134555313455531345553134