2021-01-23 21:09:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use Pterodactyl\Models\ApiKey;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
class ApiKeyFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = ApiKey::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*/
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
static $token;
|
|
|
|
|
|
|
|
return [
|
|
|
|
'key_type' => ApiKey::TYPE_APPLICATION,
|
2022-05-22 22:05:58 +02:00
|
|
|
'identifier' => ApiKey::generateTokenIdentifier(),
|
2021-07-11 19:27:15 +02:00
|
|
|
'token' => $token ?: $token = encrypt(Str::random(ApiKey::KEY_LENGTH)),
|
2021-01-23 21:09:16 +01:00
|
|
|
'allowed_ips' => null,
|
|
|
|
'memo' => 'Test Function Key',
|
|
|
|
'created_at' => Carbon::now(),
|
|
|
|
'updated_at' => Carbon::now(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|