2021-01-23 20:09:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Ramsey\Uuid\Uuid;
|
2022-05-29 21:52:14 +00:00
|
|
|
use Illuminate\Support\Str;
|
2021-01-23 20:09:16 +00:00
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
class UserFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = User::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*/
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
static $password;
|
|
|
|
|
|
|
|
return [
|
2022-05-29 21:52:14 +00:00
|
|
|
'external_id' => null,
|
2021-01-23 20:09:16 +00:00
|
|
|
'uuid' => Uuid::uuid4()->toString(),
|
2022-06-26 20:37:43 +00:00
|
|
|
'username' => $this->faker->userName . '_' . Str::random(10),
|
2022-05-29 21:52:14 +00:00
|
|
|
'email' => Str::random(32) . '@example.com',
|
2021-01-23 20:09:16 +00:00
|
|
|
'password' => $password ?: $password = bcrypt('password'),
|
|
|
|
'language' => 'en',
|
|
|
|
'root_admin' => false,
|
|
|
|
'use_totp' => false,
|
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Indicate that the user is an admin.
|
|
|
|
*/
|
2023-02-23 19:30:16 +00:00
|
|
|
public function admin(): static
|
2021-01-23 20:09:16 +00:00
|
|
|
{
|
2022-06-26 20:37:43 +00:00
|
|
|
return $this->state(['root_admin' => true]);
|
2021-01-23 20:09:16 +00:00
|
|
|
}
|
|
|
|
}
|