misc_pterodactyl-panel/database/Factories/UserFactory.php

49 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Database\Factories;
use Carbon\Carbon;
use Ramsey\Uuid\Uuid;
use Illuminate\Support\Str;
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 [
'external_id' => null,
'uuid' => Uuid::uuid4()->toString(),
2022-06-26 20:37:43 +00:00
'username' => $this->faker->userName . '_' . Str::random(10),
'email' => Str::random(32) . '@example.com',
'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.
*/
public function admin(): Factory
{
2022-06-26 20:37:43 +00:00
return $this->state(['root_admin' => true]);
}
}