encrypter = $encrypter; $this->repository = $repository; } /** * Create a new API key for the Panel using the permissions passed in the data request. * This will automatically generate an identifer and an encrypted token that are * stored in the database. * * @param array $data * @return \Pterodactyl\Models\APIKey * * @throws \Pterodactyl\Exceptions\Model\DataValidationException */ public function handle(array $data): APIKey { $data = array_merge($data, [ 'identifier' => str_random(APIKey::IDENTIFIER_LENGTH), 'token' => $this->encrypter->encrypt(str_random(APIKey::KEY_LENGTH)), ]); $instance = $this->repository->create($data, true, true); return $instance; } }