Skip to content

Commit

Permalink
Add nova_set_setting_value helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarpsvo committed Jan 18, 2021
1 parent 7fa5c35 commit eef911c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/NovaSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ public static function getSettings(array $settingKeys = null)
})->pluck('value', 'key')->toArray();
}

public static function setSettingValue($settingKey, $value = null)
{
$setting = static::getSettingsModel()::firstOrCreate(['key' => $settingKey]);
$setting->value = $value;
$setting->save();
return $setting;
}

public static function getSettingsModel(): string
{
return config('nova-settings.models.settings', Settings::class);
Expand Down
7 changes: 7 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ function nova_get_setting($settingKey, $default = null)
return NovaSettings::getSetting($settingKey, $default);
}
}

if (!function_exists('nova_set_setting_value')) {
function nova_set_setting_value($settingKey, $value = null)
{
return NovaSettings::setSettingValue($settingKey, $value);
}
}

0 comments on commit eef911c

Please sign in to comment.