我在表中插入虚假记录,但它不在数据库中移动。您可以检查我的代码如下: -在laravel中插入查询
public function up()
{
Schema::create('employees', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email',255)->unique();
$table->string('contact_number');
$table->timestamps();
});
$faker = Faker\Factory::create();
$limit = 33;
for ($i = 0; $i < $limit; $i++) {
DB::table('employees')->insert([
'name' => $faker->name,
'email' => $faker->unique()->email,
'contact_number' => $faker->phoneNumber,
]);
}
}
有人可以告诉我我在哪里错了吗?请帮我解决一下这个。
我试过,但没有成功。 –
请发布您的播种代码。 –
public function run() $ faker = Faker \ Factory :: create(); $ limit = 33; ($ i = 0; $ i <$ limit; $ i ++)DB :: table('employees') - > insert('name'=> $ faker-> name, 'email' => $ faker-> unique() - >电子邮件, 'contact_number'=> $ faker-> phoneNumber, ]); } } –