Closed TheOddler closed 3 years ago
For now I created a helper class:
class NovaSettingsHelper
{
public static function setSetting($settingKey, $value)
{
$setting = Settings::where('key', $settingKey)->first();
if (!$setting) {
$setting = new Settings([
'key' => $settingKey,
]);
}
$setting->value = $value;
$setting->save();
}
}
Hey @TheOddler! Sorry for the delay. :)
I added a helper nova_set_setting_value
in version 3.1.1.
I decided not to name it nova_set_setting
due to the similarity with nova_get_setting
. A typo like that could be costly.
Thanks for the suggestion and example! Good luck!
Cool, thanks a lot! And fair point, being a bit more verbose can sometimes save a lot of headache.
Is there a way to change the settings through code? Something like the helper functions, but to set. For example:
nova_set_setting
.I want to use this in our automated tests, and was wondering if there is a better way then to just manually create the models in the database.