我在表中插入虛假記錄,但它不在數據庫中移動。您可以檢查我的代碼如下: -在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, ]); } } –