diff --git a/app/Http/Controllers/Admin/SettingsController.php b/app/Http/Controllers/Admin/SettingsController.php index ff2f0b85..db346f39 100644 --- a/app/Http/Controllers/Admin/SettingsController.php +++ b/app/Http/Controllers/Admin/SettingsController.php @@ -159,8 +159,22 @@ class SettingsController extends Controller } $nullable = $rpType->allowsNull(); - if ($nullable) $settingsClass->$key = $request->input($key) ?? null; - else $settingsClass->$key = $request->input($key); + $inputValue = $nullable ? ($request->input($key) ?? null) : $request->input($key); + + // using currency facade for reward and other currency fields + $currencyKeys = [ + 'reward', + 'credits_reward_after_verify_discord', + 'credits_reward_after_verify_email', + 'initial_credits', + 'min_credits_to_make_server', + ]; + + if (in_array($key, $currencyKeys) && $inputValue !== null && $inputValue !== '') { + $inputValue = Currency::prepareForDatabase($inputValue); + } + + $settingsClass->$key = $inputValue; } $settingsClass->save(); diff --git a/app/Settings/ReferralSettings.php b/app/Settings/ReferralSettings.php index b6387fef..da47d2e0 100644 --- a/app/Settings/ReferralSettings.php +++ b/app/Settings/ReferralSettings.php @@ -18,17 +18,17 @@ class ReferralSettings extends Settings return 'referral'; } - /** - * Casts the settings to the correct type. - * - * @return array - */ - public static function casts(): array - { - return [ - 'reward' => CurrencyCast::class, - ]; - } + // /** + // * Casts the settings to the correct type. + // * + // * @return array + // */ + // public static function casts(): array + // { + // return [ + // 'reward' => CurrencyCast::class, + // ]; + // } /** * Summary of validations array diff --git a/app/Settings/UserSettings.php b/app/Settings/UserSettings.php index f2ecec63..32f7e4c5 100644 --- a/app/Settings/UserSettings.php +++ b/app/Settings/UserSettings.php @@ -25,20 +25,20 @@ class UserSettings extends Settings return 'user'; } - /** - * Casts the settings to the correct type. - * - * @return array - */ - public static function casts(): array - { - return [ - 'credits_reward_after_verify_discord' => CurrencyCast::class, - 'credits_reward_after_verify_email' => CurrencyCast::class, - 'initial_credits' => CurrencyCast::class, - 'min_credits_to_make_server' => CurrencyCast::class, - ]; - } + // /** + // * Casts the settings to the correct type. + // * + // * @return array + // */ + // public static function casts(): array + // { + // return [ + // 'credits_reward_after_verify_discord' => CurrencyCast::class, + // 'credits_reward_after_verify_email' => CurrencyCast::class, + // 'initial_credits' => CurrencyCast::class, + // 'min_credits_to_make_server' => CurrencyCast::class, + // ]; + // } /** * Summary of validations array