Path: blob/1.0-develop/database/Factories/ApiKeyFactory.php
7458 views
<?php12namespace Database\Factories;34use Carbon\Carbon;5use Illuminate\Support\Str;6use Pterodactyl\Models\ApiKey;7use Illuminate\Database\Eloquent\Factories\Factory;89class ApiKeyFactory extends Factory10{11/**12* The name of the factory's corresponding model.13*14* @var string15*/16protected $model = ApiKey::class;1718/**19* Define the model's default state.20*/21public function definition(): array22{23static $token;2425return [26'key_type' => ApiKey::TYPE_APPLICATION,27'identifier' => ApiKey::generateTokenIdentifier(ApiKey::TYPE_APPLICATION),28'token' => $token ?: $token = encrypt(Str::random(ApiKey::KEY_LENGTH)),29'allowed_ips' => null,30'memo' => 'Test Function Key',31'created_at' => Carbon::now(),32'updated_at' => Carbon::now(),33];34}35}363738