laravel/database/factories/UserFactory.php

45 lines
1.0 KiB
PHP
Raw Normal View History

2015-05-08 08:42:04 -05:00
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
2019-09-10 17:26:00 +02:00
use Illuminate\Support\Str;
/**
2022-01-21 12:32:08 +00:00
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
*/
class UserFactory extends Factory
{
/**
* The current password being used by the factory.
*/
protected static ?string $password;
/**
* Define the model's default state.
*
2022-02-09 21:24:35 +01:00
* @return array<string, mixed>
*/
public function definition(): array
{
return [
2022-06-22 11:02:43 -05:00
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
];
}
/**
2021-02-16 10:58:28 -06:00
* Indicate that the model's email address should be unverified.
*/
public function unverified(): static
{
2022-08-20 12:22:43 -05:00
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
}