From d9d776e5da56de5497cc664adf94f51b1ac8ec47 Mon Sep 17 00:00:00 2001 From: IceToast Date: Fri, 10 Feb 2023 00:31:27 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A6=BA=20Added=20Validation=20to?= =?UTF-8?q?=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Settings/DiscordSettings.php | 18 +++++++++++++++++- app/Settings/GeneralSettings.php | 17 +++++++++++++---- app/Settings/InvoiceSettings.php | 22 ++++++++++++++++++++-- app/Settings/LocaleSettings.php | 15 +++++++++++++++ app/Settings/MailSettings.php | 19 +++++++++++++++++++ app/Settings/PterodactylSettings.php | 14 ++++++++++++++ app/Settings/ReferralSettings.php | 16 ++++++++++++++++ app/Settings/ServerSettings.php | 14 ++++++++++++++ app/Settings/TicketSettings.php | 12 ++++++++++++ app/Settings/UserSettings.php | 22 ++++++++++++++++++++++ app/Settings/WebsiteSettings.php | 19 +++++++++++++++++++ 11 files changed, 181 insertions(+), 7 deletions(-) diff --git a/app/Settings/DiscordSettings.php b/app/Settings/DiscordSettings.php index e5e931af..08bc603a 100644 --- a/app/Settings/DiscordSettings.php +++ b/app/Settings/DiscordSettings.php @@ -33,7 +33,23 @@ class DiscordSettings extends Settings } /** - * Summary of optionTypes + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'bot_token' => 'nullable|string', + 'client_id' => 'nullable|string', + 'client_secret' => 'nullable|string', + 'guild_id' => 'nullable|string', + 'invite_url' => 'nullable|string|url', + 'role_id' => 'nullable|string', + ]; + } + + /** + * Summary of optionInputData array * Only used for the settings page * @return array>> */ diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php index 0225ab0c..119f8c17 100644 --- a/app/Settings/GeneralSettings.php +++ b/app/Settings/GeneralSettings.php @@ -34,16 +34,25 @@ class GeneralSettings extends Settings ]; } + /** + * Summary of validations array + * @return array + */ public static function getValidations() { - // create validation rules that can be used in the controller return [ - 'main_site' => 'required|string|max:1', + 'main_site' => 'nullable|string', 'credits_display_name' => 'required|string', 'initial_user_credits' => 'required|numeric', 'initial_server_limit' => 'required|numeric', - 'recaptcha_enabled' => 'required|boolean', - + 'recaptcha_enabled' => 'nullable|string', + 'recaptcha_site_key' => 'nullable|string', + 'recaptcha_secret_key' => 'nullable|string', + 'phpmyadmin_url' => 'nullable|string', + 'alert_enabled' => 'nullable|string', + 'alert_type' => 'nullable|string', + 'alert_message' => 'nullable|string', + 'theme' => 'required|string' ]; } diff --git a/app/Settings/InvoiceSettings.php b/app/Settings/InvoiceSettings.php index 9f0a7bf4..36118160 100644 --- a/app/Settings/InvoiceSettings.php +++ b/app/Settings/InvoiceSettings.php @@ -27,6 +27,24 @@ class InvoiceSettings extends Settings return 'invoice'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'company_address' => 'nullable|string', + 'company_mail' => 'nullable|string', + 'company_name' => 'nullable|string', + 'company_phone' => 'nullable|string', + 'company_vat' => 'nullable|string', + 'company_website' => 'nullable|string', + 'enabled' => 'nullable|string', + 'prefix' => 'nullable|string', + ]; + } + /** * Summary of optionTypes * Only used for the settings page @@ -56,9 +74,9 @@ class InvoiceSettings extends Settings 'description' => 'The phone of your company.', ], 'company_vat' => [ - 'label' => 'Company VAT', + 'label' => 'Company VAT ID', 'type' => 'string', - 'description' => 'The VAT of your company.', + 'description' => 'The VAT ID of your company.', ], 'company_website' => [ 'label' => 'Company Website', diff --git a/app/Settings/LocaleSettings.php b/app/Settings/LocaleSettings.php index 8256acee..3a62aeab 100644 --- a/app/Settings/LocaleSettings.php +++ b/app/Settings/LocaleSettings.php @@ -21,6 +21,21 @@ class LocaleSettings extends Settings return 'locale'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'available' => 'nullable|array', + 'clients_can_change' => 'nullable|string', + 'datatables' => 'nullable|string', + 'default' => 'nullable|string', + 'dynamic' => 'nullable|string', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/MailSettings.php b/app/Settings/MailSettings.php index bf73d10b..17787ee1 100644 --- a/app/Settings/MailSettings.php +++ b/app/Settings/MailSettings.php @@ -50,6 +50,25 @@ class MailSettings extends Settings } } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'mail_host' => 'nullable|string', + 'mail_port' => 'nullable|int', + 'mail_username' => 'nullable|string', + 'mail_password' => 'nullable|string', + 'mail_encryption' => 'nullable|string', + 'mail_from_address' => 'nullable|string', + 'mail_from_name' => 'nullable|string', + 'mail_mailer' => 'nullable|string', + 'mail_enabled' => 'nullable|boolean', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/PterodactylSettings.php b/app/Settings/PterodactylSettings.php index 7bd1dda4..2f180483 100644 --- a/app/Settings/PterodactylSettings.php +++ b/app/Settings/PterodactylSettings.php @@ -37,6 +37,20 @@ class PterodactylSettings extends Settings return str_ends_with($this->panel_url, '/') ? $this->panel_url : $this->panel_url . '/'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'panel_url' => 'required|string|url', + 'admin_token' => 'required|string', + 'user_token' => 'required|string', + 'per_page_limit' => 'required|integer|min:1|max:10000', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/ReferralSettings.php b/app/Settings/ReferralSettings.php index 87b3b497..d88cd8b2 100644 --- a/app/Settings/ReferralSettings.php +++ b/app/Settings/ReferralSettings.php @@ -23,6 +23,22 @@ class ReferralSettings extends Settings return 'referral'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'allowed' => 'nullable|string', + 'always_give_commission' => 'nullable|boolean', + 'enabled' => 'nullable|boolean', + 'reward' => 'nullable|numeric', + 'mode' => 'nullable|string', + 'percentage' => 'nullable|numeric', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/ServerSettings.php b/app/Settings/ServerSettings.php index 0e8084bf..181bd51a 100644 --- a/app/Settings/ServerSettings.php +++ b/app/Settings/ServerSettings.php @@ -19,6 +19,20 @@ class ServerSettings extends Settings return 'server'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'allocation_limit' => 'required|integer|min:0', + 'creation_enabled' => 'nullable|string', + 'enable_upgrade' => 'nullable|string', + 'charge_first_hour' => 'nullable|string', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/TicketSettings.php b/app/Settings/TicketSettings.php index 3c28f701..b794f06f 100644 --- a/app/Settings/TicketSettings.php +++ b/app/Settings/TicketSettings.php @@ -15,6 +15,18 @@ class TicketSettings extends Settings return 'ticket'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'enabled' => 'nullable|string', + 'notify' => 'nullable|string', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/UserSettings.php b/app/Settings/UserSettings.php index ec6d2cbd..b8525429 100644 --- a/app/Settings/UserSettings.php +++ b/app/Settings/UserSettings.php @@ -35,6 +35,28 @@ class UserSettings extends Settings return 'user'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'credits_reward_after_verify_discord' => 'required|numeric', + 'credits_reward_after_verify_email' => 'required|numeric', + 'force_discord_verification' => 'nullable|string', + 'force_email_verification' => 'nullable|string', + 'initial_credits' => 'required|numeric', + 'initial_server_limit' => 'required|numeric', + 'min_credits_to_make_server' => 'required|numeric', + 'server_limit_after_irl_purchase' => 'required|numeric', + 'server_limit_after_verify_discord' => 'required|numeric', + 'server_limit_after_verify_email' => 'required|numeric', + 'register_ip_check' => 'nullable|string', + 'creation_enabled' => 'nullable|string', + ]; + } + /** * Summary of optionTypes * Only used for the settings page diff --git a/app/Settings/WebsiteSettings.php b/app/Settings/WebsiteSettings.php index 27539381..95ee6393 100644 --- a/app/Settings/WebsiteSettings.php +++ b/app/Settings/WebsiteSettings.php @@ -28,6 +28,25 @@ class WebsiteSettings extends Settings return 'website'; } + /** + * Summary of validations array + * @return array + */ + public static function getValidations() + { + return [ + 'motd_enabled' => 'nullable|string', + 'motd_message' => 'nullable|string', + 'show_imprint' => 'nullable|string', + 'show_privacy' => 'nullable|string', + 'show_tos' => 'nullable|string', + 'useful_links_enabled' => 'nullable|string', + 'enable_login_logo' => 'nullable|string', + 'seo_title' => 'nullable|string', + 'seo_description' => 'nullable|string', + ]; + } + /** * Summary of optionTypes