You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/database/factories/UserFactory.php

41 lines
1002 B
PHP

<?php
namespace Database\Factories;
use App\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
class UserFactory extends Factory
{
protected $model = User::class;
public function definition(): array
{
return [
'name' => fake()->name(),
'username' => str_replace('.', '', fake()->unique()->userName()),
'email' => Str::random(8).fake()->unique()->safeEmail(),
'password' => Hash::make('password'),
'remember_token' => Str::random(10),
'email_verified_at' => now(),
'last_active_at' => now(),
];
}
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
public function admin(): static
{
return $this->state(fn (array $attributes) => [
'is_admin' => true,
]);
}
}