PterodactylSettings.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace App\Settings;
  3. use Spatie\LaravelSettings\Settings;
  4. class PterodactylSettings extends Settings
  5. {
  6. public string $admin_token;
  7. public string $user_token;
  8. public string $panel_url;
  9. public int $per_page_limit;
  10. public static function group(): string
  11. {
  12. return 'pterodactyl';
  13. }
  14. public static function encrypted(): array
  15. {
  16. return [
  17. 'admin_token',
  18. 'user_token',
  19. ];
  20. }
  21. /**
  22. * Get url with ensured ending backslash
  23. *
  24. * @return string
  25. */
  26. public function getUrl(): string
  27. {
  28. return str_ends_with($this->panel_url, '/') ? $this->panel_url : $this->panel_url . '/';
  29. }
  30. /**
  31. * Summary of validations array
  32. * @return array<string, string>
  33. */
  34. public static function getValidations()
  35. {
  36. return [
  37. 'panel_url' => 'required|string|url',
  38. 'admin_token' => 'required|string',
  39. 'user_token' => 'required|string',
  40. 'per_page_limit' => 'required|integer|min:1|max:10000',
  41. ];
  42. }
  43. /**
  44. * Summary of optionTypes
  45. * Only used for the settings page
  46. * @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
  47. */
  48. public static function getOptionInputData()
  49. {
  50. return [
  51. 'category_icon' => 'fas fa-server',
  52. 'panel_url' => [
  53. 'label' => 'Panel URL',
  54. 'type' => 'string',
  55. 'description' => 'The URL to your Pterodactyl panel.',
  56. ],
  57. 'admin_token' => [
  58. 'label' => 'Admin Token',
  59. 'type' => 'string',
  60. 'description' => 'The admin user token for your Pterodactyl panel.',
  61. ],
  62. 'user_token' => [
  63. 'label' => 'User Token',
  64. 'type' => 'string',
  65. 'description' => 'The user token for your Pterodactyl panel.',
  66. ],
  67. 'per_page_limit' => [
  68. 'label' => 'Per Page Limit',
  69. 'type' => 'number',
  70. 'description' => 'The number of servers to show per page.',
  71. ],
  72. ];
  73. }
  74. }