Mercurial > borealpoint
comparison database/factories/UserFactory.php @ 0:9d7dcd54c677
Initial Commit and package setup
| author | luka |
|---|---|
| date | Sat, 23 Aug 2025 22:20:51 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:9d7dcd54c677 |
|---|---|
| 1 <?php | |
| 2 | |
| 3 namespace Database\Factories; | |
| 4 | |
| 5 use Illuminate\Database\Eloquent\Factories\Factory; | |
| 6 use Illuminate\Support\Facades\Hash; | |
| 7 use Illuminate\Support\Str; | |
| 8 | |
| 9 /** | |
| 10 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User> | |
| 11 */ | |
| 12 class UserFactory extends Factory | |
| 13 { | |
| 14 /** | |
| 15 * The current password being used by the factory. | |
| 16 */ | |
| 17 protected static ?string $password; | |
| 18 | |
| 19 /** | |
| 20 * Define the model's default state. | |
| 21 * | |
| 22 * @return array<string, mixed> | |
| 23 */ | |
| 24 public function definition(): array | |
| 25 { | |
| 26 return [ | |
| 27 'name' => fake()->name(), | |
| 28 'email' => fake()->unique()->safeEmail(), | |
| 29 'email_verified_at' => now(), | |
| 30 'password' => static::$password ??= Hash::make('password'), | |
| 31 'remember_token' => Str::random(10), | |
| 32 ]; | |
| 33 } | |
| 34 | |
| 35 /** | |
| 36 * Indicate that the model's email address should be unverified. | |
| 37 */ | |
| 38 public function unverified(): static | |
| 39 { | |
| 40 return $this->state(fn (array $attributes) => [ | |
| 41 'email_verified_at' => null, | |
| 42 ]); | |
| 43 } | |
| 44 } |
