jeudi 29 octobre 2015

How to concatenate Faker's random first name and its last name to a full name in Laravel 5

I am trying to use Faker in Laravel 5. Now I need to create some users in my User table, I choose Faker.

I know how to create random firstname, lastname or userName, but I want to concatenate each FN and LN to be username, how can I do that? Here is my codes in seeder file.

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))
        ]);
    }
}

image of seeder content




Aucun commentaire:

Enregistrer un commentaire