hasMany(PersonalAccessToken::class); } /** * Creates a new personal access token for the user. The token will be returned * as the first element of the array, and the plain-text token will be the second. * * @param string $description * @param string[] $abilities * @return array */ public function createToken(string $description, array $abilities = ['*']): array { /** @var \Pterodactyl\Models\PersonalAccessToken $token */ $token = $this->tokens()->create([ 'user_id' => $this->id, 'description' => $description, 'token' => hash('sha256', $plain = Str::random(PersonalAccessToken::TOKEN_LENGTH)), 'token_id' => PersonalAccessToken::generateTokenIdentifier(), 'abilities' => $abilities, ]); return [$token, $token->token_id . $plain]; } }