Skip to content

Commit

Permalink
Merge pull request #29 from Punksolid/newUserFactory
Browse files Browse the repository at this point in the history
Updated user factory in default directory
  • Loading branch information
bobbyiliev committed Oct 21, 2021
2 parents b2d3f3c + 9d5b95a commit c53736c
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions database/factories/UserFactory.php
@@ -1,25 +1,33 @@
<?php

use Faker\Generator as Faker;
namespace Database\Factories;

/*
|--------------------------------------------------------------------------
| Model Factories
|--------------------------------------------------------------------------
|
| This directory should contain each of the model factory definitions for
| your application. Factories provide a convenient way to generate new
| model instances for testing / seeding your application's database.
|
*/
use App\User;
use Illuminate\Database\Eloquent\Factories\Factory;

$factory->define(App\User::class, function (Faker $faker) {
static $password;
class UserFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = User::class;

return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
});
/**
* Define the model's default state.
*
* @return array
*/
public function definition(): array
{
static $password;

return [
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'password' => $password ?: $password = bcrypt('secret'),
'remember_token' => str_random(10),
];
}
}

0 comments on commit c53736c

Please sign in to comment.