Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/database/Factories/ApiKeyFactory.php
7458 views
1
<?php
2
3
namespace Database\Factories;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\Str;
7
use Pterodactyl\Models\ApiKey;
8
use Illuminate\Database\Eloquent\Factories\Factory;
9
10
class ApiKeyFactory extends Factory
11
{
12
/**
13
* The name of the factory's corresponding model.
14
*
15
* @var string
16
*/
17
protected $model = ApiKey::class;
18
19
/**
20
* Define the model's default state.
21
*/
22
public function definition(): array
23
{
24
static $token;
25
26
return [
27
'key_type' => ApiKey::TYPE_APPLICATION,
28
'identifier' => ApiKey::generateTokenIdentifier(ApiKey::TYPE_APPLICATION),
29
'token' => $token ?: $token = encrypt(Str::random(ApiKey::KEY_LENGTH)),
30
'allowed_ips' => null,
31
'memo' => 'Test Function Key',
32
'created_at' => Carbon::now(),
33
'updated_at' => Carbon::now(),
34
];
35
}
36
}
37
38