我正在尝试在Laravel 5中使用Faker。现在,我需要在User表中创建一些用户,我选择Faker。
我知道如何创建随机的名字,姓氏或用户名,但是我想将每个FN和LN连接为用户名,我该怎么做?这是我的种子文件中的代码。
public function run()
{
$faker = Faker::create();
foreach(range(1, 10) as $index) {
User::create([
'first_name' => $faker->firstName($gender = null|'male'|'female'),
'last_name' => $faker->lastName,
'username' => $faker->userName(),
'email' => $faker->email,
'password' => bcrypt($faker->password(6))
]);
}
}
Run Code Online (Sandbox Code Playgroud)
