Laravel 5.2 种子特定数据数组

Laravel 5.2 seed specific data array

我正在尝试使用一些特定 内容为我的数据库播种 以启动我的应用程序。我知道 Faker 以及如何使用它(我为我的用户做的)。现在我想用(很多)不是随机生成的记录填充 table,所以不是由 Faker 创建的。

例如我想table与一些(比方说30个)俱乐部,这样我就可以生成一些hundered用户,他们是其中一个的成员$faker->randomElement.

的 30 个俱乐部

有没有其他方法可以输入 30 次?

   $club = Club::create(array(
        'name' => 'FC Barcelona',
        'number' => '001',
    ));    

无法在 laravel (5.2) 文档中找到它。只解释了Faker

谢谢

您可以做的是创建一个带有俱乐部的数组并为它们播种,在 UsersDatabaseSeeder 中您可以循环创建任意数量的记录并为每个随机分配俱乐部。

编辑

$clubs = [['prop1'=> 'val1',], ['prop1' => 'val2']];
\DB::table('clubs')->insert($clubs);
Content::create(array(
            'content_title' => 'Swiss Army Man',
            'content_link' => 'www.Youtube.com',
            'description' => 'This movie is .....',
            'content_title' => 'Movie',
            'image_path' =>  'images/m1.jpg',
            'year' => '2014-12-4'
        ));

   Content::create(array(
            'content_title' => 'Me Before You',
            'content_link' => 'www.Youtube.com',
            'description' => 'asdddddd',
            'content_title' => 'Movie',
            'image_path' =>  'images/m2.jpg',
            'year' => '2016-6-4'

        ));
,,, So You can create as many as u want ;)