2021-01-23 12:09:16 -08:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2021-01-23 12:09:16 -08:00
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Support\Facades\Date;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
|
use Ramsey\Uuid\Uuid;
|
2021-01-23 12:09:16 -08:00
|
|
|
|
2025-12-30 15:27:11 -05:00
|
|
|
/**
|
2026-10-05 18:10:18 -04:00
|
|
|
* @extends Factory<User>
|
2025-12-30 15:27:11 -05:00
|
|
|
*/
|
2021-01-23 12:09:16 -08:00
|
|
|
class UserFactory extends Factory
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Define the model's default state.
|
|
|
|
|
*/
|
|
|
|
|
public function definition(): array
|
|
|
|
|
{
|
|
|
|
|
static $password;
|
|
|
|
|
|
|
|
|
|
return [
|
2022-05-29 17:52:14 -04:00
|
|
|
'external_id' => null,
|
2021-01-23 12:09:16 -08:00
|
|
|
'uuid' => Uuid::uuid4()->toString(),
|
2026-10-05 18:10:18 -04:00
|
|
|
'username' => fake()->userName().'_'.Str::random(10),
|
|
|
|
|
'email' => Str::random(32).'@example.com',
|
|
|
|
|
'name_first' => fake()->firstName(),
|
|
|
|
|
'name_last' => fake()->lastName(),
|
2021-01-23 12:09:16 -08:00
|
|
|
'password' => $password ?: $password = bcrypt('password'),
|
2026-10-05 18:10:18 -04:00
|
|
|
'remember_token' => Str::random(10),
|
2021-01-23 12:09:16 -08:00
|
|
|
'language' => 'en',
|
|
|
|
|
'root_admin' => false,
|
|
|
|
|
'use_totp' => false,
|
2026-10-05 18:10:18 -04:00
|
|
|
'created_at' => Date::now(),
|
|
|
|
|
'updated_at' => Date::now(),
|
2021-01-23 12:09:16 -08:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Indicate that the user is an admin.
|
|
|
|
|
*/
|
2023-02-23 12:30:16 -07:00
|
|
|
public function admin(): static
|
2021-01-23 12:09:16 -08:00
|
|
|
{
|
2022-06-26 16:37:43 -04:00
|
|
|
return $this->state(['root_admin' => true]);
|
2021-01-23 12:09:16 -08:00
|
|
|
}
|
|
|
|
|
}
|