Seed multiple rows at once laravel 5

前端 未结 6 1095
情深已故
情深已故 2021-02-01 12:44

I\'m currently trying to seed my users table. If I try it like this with 2 rows, it fails. It works fine if I just use a single array instead of the 2 arrays inside the $users a

6条回答
  •  北海茫月
    2021-02-01 13:19

    public function run()
    {
        //
        for ($i=0; $i < 1000; $i++) { 
             DB::table('seo_contents')->insert([
                'title' => str_random(10),
                'content' => str_random(100),
                'created_at'=>date('Y-m-d H:i:s'),
                'updated_at'=>date('Y-m-d H:i:s'),
    
            ]);
        }
    
    }
    

提交回复
热议问题