在 Laravel 上播种多个特定数据

Seed Multiple Specific Data on Laravel

我想使用 locals3rackspace[= 为数据库 table 播种22=] 在 Laravel 上使用数据库播种器。但是,如果我将这三个特定名称与 $faker->randomElement() 方法一起使用,它只会多次填充相同的名称,而这正是我不需要的。如果可能的话,我还想使用 s3rackspace 存储名称为不同的列设置不同的值。

$factory->define(App\Storage::class, function (\Faker\Generator $faker) {
    return [
        'storage' => $faker->randomElement(['s3', 'local', 'rackspace']),
        's3-key' => null,
        's3-secret' => null,
        's3-region' => null,
        's3-bucket' => null,
        'rackspace-username' => null,
        'rackspace-key' => null,
        'rackspace-container' => null,
        'status' => 'active'
    ];
})

实现此目标的最佳方法是什么?

Faker/Provider/Baser.class 中有一个错误,它在 randomElement 函数中使用了这行代码,它一遍又一遍地复制相同的随机元素由于使用 static:: 关键字

的事实,相同的实例
static::randomElements($array, 1);

我会报告的,暂时使用这段代码:

$faker->randomElements(['s3', 'local', 'rackspace'],1)[0]