laravel seeding

提前配置测试数据

php artisan make:seeder UserTableSeeder

write random data

insert([
        		'name'=>str_random(10),
        		'email'=>str_random(10).'@gmail.com',
        		'password'=>bcrypt('secret'),
        	]);
    }
}

and config run in DatabaseSeeder.php

 public function run()
    {
    	$this->call([
					UserTableSeeder::class,
    		]);
    }

composer dump-autoload

php artisan db:seed

laravel seeding_第1张图片

laravel seeding_第2张图片

你可能感兴趣的:(laravel seeding)