private function createOrUpdateThemeSetting($theme_slug, $key, $value) { $setting = array('theme_slug' => $theme_slug, 'key' => $key, 'value' => $value); $theme_setting = ThemeSetting::where('theme_slug', '=', $theme_slug)->where('key', '=', $key)->first(); if (isset($theme_setting->id)) { $theme_setting->update($setting); $theme_setting->save(); } else { ThemeSetting::create($setting); } }
public static function getThemeSettings() { // Get the Active Theme and the Theme Settings $active_theme = Setting::first()->theme; $theme_settings = ThemeSetting::where('theme_slug', '=', $active_theme)->get(); // Create an empty array to fill with theme settings $key_values = array(); // loop through each key value and put into array accordingly foreach ($theme_settings as $setting) { $key_values[$setting->key] = $setting->value; } return (object) $key_values; }