Add support for generating random users

This commit is contained in:
Alex Thomassen 2020-03-23 13:02:55 +01:00
parent 5370cfefeb
commit 31c18affb9
Signed by: Alex
GPG Key ID: 10BD786B5F6FF5DE
3 changed files with 23 additions and 1 deletions

View File

@ -5,6 +5,7 @@
use App\User;
use Faker\Generator as Faker;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Hash;
/*
|--------------------------------------------------------------------------
@ -19,10 +20,12 @@ use Illuminate\Support\Str;
$factory->define(User::class, function (Faker $faker) {
return [
'username' => $faker->userName,
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'password' => Hash::make('Kaffekopp123'),
'admin' => false,
'remember_token' => Str::random(10),
];
});

View File

@ -12,6 +12,9 @@ class DatabaseSeeder extends Seeder
public function run()
{
$this->call(UserSeeder::class);
// Uncomment if you want to add 20 random users.
// Alternatively run `php artisan db:seed --class=RandomUserSeeder`
//$this->call(RandomUserSeeder::class);
$this->call(BlogPostSeeder::class);
}
}

View File

@ -0,0 +1,16 @@
<?php
use Illuminate\Database\Seeder;
class RandomUserSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\User::class, 20)->create();
}
}