提前配置测试数据
php artisan make:seeder UserTableSeeder
write random data
<?php
use Illuminate\\Database\\Seeder;
use Illuminate\\Support\\Facades\\DB;
class UserTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table(\'users\')->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