Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/database/Factories/UserFactory.php
7458 views
1
<?php
2
3
namespace Database\Factories;
4
5
use Carbon\Carbon;
6
use Ramsey\Uuid\Uuid;
7
use Illuminate\Support\Str;
8
use Pterodactyl\Models\User;
9
use Illuminate\Database\Eloquent\Factories\Factory;
10
11
class UserFactory extends Factory
12
{
13
/**
14
* The name of the factory's corresponding model.
15
*
16
* @var string
17
*/
18
protected $model = User::class;
19
20
/**
21
* Define the model's default state.
22
*/
23
public function definition(): array
24
{
25
static $password;
26
27
return [
28
'external_id' => null,
29
'uuid' => Uuid::uuid4()->toString(),
30
'username' => $this->faker->userName . '_' . Str::random(10),
31
'email' => Str::random(32) . '@example.com',
32
'name_first' => $this->faker->firstName,
33
'name_last' => $this->faker->lastName,
34
'password' => $password ?: $password = bcrypt('password'),
35
'language' => 'en',
36
'root_admin' => false,
37
'use_totp' => false,
38
'created_at' => Carbon::now(),
39
'updated_at' => Carbon::now(),
40
];
41
}
42
43
/**
44
* Indicate that the user is an admin.
45
*/
46
public function admin(): static
47
{
48
return $this->state(['root_admin' => true]);
49
}
50
}
51
52