Speed up user factory by only bcrypting once

This commit is contained in:
snipe 2017-10-27 20:35:13 -07:00
parent 2d758be0e1
commit 7e0c33d535

View file

@ -2,19 +2,17 @@
use App\Models\Company;
$password = bcrypt('password');
$factory->define(App\Models\User::class, function (Faker\Generator $faker) {
$factory->define(App\Models\User::class, function (Faker\Generator $faker) use ($password) {
return [
'first_name' => $faker->firstName,
'last_name' => $faker->lastName,
'username' => $faker->username,
'password' => bcrypt('password'),
'password' => $password,
'permissions' => '{"user":"0"}',
'email' => $faker->safeEmail,
'company_id' => function () {
return factory(App\Models\Company::class)->create()->id;
},
'company_id' => rand(1,4),
'locale' => $faker->locale,
'employee_num' => $faker->numberBetween(3500, 35050),
'jobtitle' => $faker->jobTitle,