GeneralSettings.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. namespace App\Settings;
  3. use Spatie\LaravelSettings\Settings;
  4. class GeneralSettings extends Settings
  5. {
  6. public bool $store_enabled;
  7. public string $credits_display_name;
  8. public bool $recaptcha_enabled;
  9. public ?string $recaptcha_site_key;
  10. public ?string $recaptcha_secret_key;
  11. public ?string $phpmyadmin_url;
  12. public bool $alert_enabled;
  13. public string $alert_type;
  14. public ?string $alert_message;
  15. public string $theme;
  16. //public int $initial_user_role; wait for Roles & Permissions PR.
  17. public static function group(): string
  18. {
  19. return 'general';
  20. }
  21. /**
  22. * Summary of validations array
  23. * @return array<string, string>
  24. */
  25. public static function getValidations()
  26. {
  27. return [
  28. 'store_enabled' => 'nullable|string',
  29. 'credits_display_name' => 'required|string',
  30. 'recaptcha_enabled' => 'nullable|string',
  31. 'recaptcha_site_key' => 'nullable|string',
  32. 'recaptcha_secret_key' => 'nullable|string',
  33. 'phpmyadmin_url' => 'nullable|string',
  34. 'alert_enabled' => 'nullable|string',
  35. 'alert_type' => 'required|in:primary,secondary,success,danger,warning,info',
  36. 'alert_message' => 'nullable|string',
  37. 'theme' => 'required|in:default,BlueInfinity' // TODO: themes should be made/loaded dynamically
  38. ];
  39. }
  40. /**
  41. * Summary of optionTypes
  42. * Only used for the settings page
  43. * @return array<array<'type'|'label'|'description'|'options', string|bool|float|int|array<string, string>>>
  44. */
  45. public static function getOptionInputData()
  46. {
  47. return [
  48. 'category_icon' => "fas fa-cog",
  49. 'store_enabled' => [
  50. 'type' => 'boolean',
  51. 'label' => 'Enable Store',
  52. 'description' => 'Enable the store for users to purchase credits.'
  53. ],
  54. 'credits_display_name' => [
  55. 'type' => 'string',
  56. 'label' => 'Credits Display Name',
  57. 'description' => 'The name of the currency used.'
  58. ],
  59. 'initial_user_credits' => [
  60. 'type' => 'number',
  61. 'label' => 'Initial User Credits',
  62. 'description' => 'The amount of credits a user gets when they register.'
  63. ],
  64. 'initial_server_limit' => [
  65. 'type' => 'number',
  66. 'label' => 'Initial Server Limit',
  67. 'description' => 'The amount of servers a user can create when they register.'
  68. ],
  69. 'recaptcha_enabled' => [
  70. 'type' => 'boolean',
  71. 'label' => 'Enable reCAPTCHA',
  72. 'description' => 'Enable reCAPTCHA on the login page.'
  73. ],
  74. 'recaptcha_site_key' => [
  75. 'type' => 'string',
  76. 'label' => 'reCAPTCHA Site Key',
  77. 'description' => 'The site key for reCAPTCHA.'
  78. ],
  79. 'recaptcha_secret_key' => [
  80. 'type' => 'string',
  81. 'label' => 'reCAPTCHA Secret Key',
  82. 'description' => 'The secret key for reCAPTCHA.'
  83. ],
  84. 'phpmyadmin_url' => [
  85. 'type' => 'string',
  86. 'label' => 'phpMyAdmin URL',
  87. 'description' => 'The URL of your phpMyAdmin installation.'
  88. ],
  89. 'alert_enabled' => [
  90. 'type' => 'boolean',
  91. 'label' => 'Enable Alert',
  92. 'description' => 'Enable an alert to be displayed on the home page.'
  93. ],
  94. 'alert_type' => [
  95. 'type' => 'select',
  96. 'label' => 'Alert Type',
  97. 'options' => [
  98. 'primary' => 'Blue',
  99. 'secondary' => 'Grey',
  100. 'success' => 'Green',
  101. 'danger' => 'Red',
  102. 'warning' => 'Orange',
  103. 'info' => 'Cyan',
  104. ],
  105. 'description' => 'The type of alert to display.'
  106. ],
  107. 'alert_message' => [
  108. 'type' => 'textarea',
  109. 'label' => 'Alert Message',
  110. 'description' => 'The message to display in the alert.'
  111. ],
  112. 'theme' => [
  113. 'type' => 'select',
  114. 'label' => 'Theme',
  115. 'options' => [
  116. 'default' => 'Default',
  117. 'BlueInfinity' => 'Blue Infinity',
  118. ], // TODO: themes should be made/loaded dynamically
  119. 'description' => 'The theme to use for the site.'
  120. ],
  121. ];
  122. }
  123. }