| 1 | <?php | = | 1 | <?php |
| 2 | 2 | |||
| <> | 3 | namespace Database\Factories; | ||
| 4 | ||||
| 5 | use App\Models\User; | |||
| 3 | /** @var \Illuminate\Database\Eloquent\Factory $factory */ | 6 | use Illuminate\Database\Eloquent\Factories\Factory; | |
| 4 | use App\User; | |||
| 5 | use Faker\Generator as Faker; | |||
| 6 | use Illuminate\Support\Str; | = | 7 | use Illuminate\Support\Str; |
| 7 | 8 | |||
| <> | 9 | class UserFactory extends Factory | ||
| 10 | { | |||
| 8 | /* | 11 | /** | |
| 9 | |-------------------------------------------------------------------------- | |||
| 10 | | Model Factories | |||
| 11 | |-------------------------------------------------------------------------- | |||
| 12 | | | |||
| 13 | | This directory should contain each of the model factory definitions for | 12 | * The name of the factory's corresponding model. | |
| 14 | | your application. Factories provide a convenient way to generate new | |||
| 15 | | model instances for testing / seeding your application's database. | |||
| 16 | | | 13 | * | |
| 14 | * @var string | |||
| 17 | */ | 15 | */ | |
| 16 | protected $model = User::class; | |||
| 18 | = | 17 | ||
| 19 | $factory->define(User::class, function (Faker $faker) { | <> | 18 | /** |
| 19 | * Define the model's default state. | |||
| 20 | * | |||
| 21 | * @return array | |||
| 22 | */ | |||
| 23 | public function definition() | |||
| 24 | { | |||
| 20 | return [ | 25 | return [ | |
| 21 | 'name' => $faker->name, | 26 | 'name' => $this->faker->name, | |
| 22 | 'email' => $faker->unique()->safeEmail, | 27 | 'email' => $this->faker->unique()->safeEmail, | |
| 23 | 'email_verified_at' => now(), | 28 | 'email_verified_at' => now(), | |
| 24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password | 29 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password | |
| 25 | 'remember_token' => Str::random(10), | 30 | 'remember_token' => Str::random(10), | |
| 26 | ]; | 31 | ]; | |
| 32 | } | |||
| 33 | ||||
| 34 | /** | |||
| 35 | * Indicate that the model's email address should be unverified. | |||
| 36 | * | |||
| 37 | * @return \Illuminate\Database\Eloquent\Factories\Factory | |||
| 38 | */ | |||
| 39 | public function unverified() | |||
| 40 | { | |||
| 41 | return $this->state(function (array $attributes) { | |||
| 42 | return [ | |||
| 43 | 'email_verified_at' => null, | |||
| 44 | ]; | |||
| 27 | }); | 45 | }); | |
| 46 | } | |||
| 47 | } |