diff --git a/app/Services/OptionRepository.php b/app/Services/OptionRepository.php index db829723..bde77f5b 100644 --- a/app/Services/OptionRepository.php +++ b/app/Services/OptionRepository.php @@ -81,9 +81,14 @@ class OptionRepository implements ArrayAccess, ConfigContract $this->items_modified = array_unique($this->items_modified); foreach ($this->items_modified as $key) { - DB::table('options') - ->where('option_name', $key) - ->update(['option_value' => $this[$key]]); + if (!DB::table('options')->where('option_name', $key)->first()) { + DB::table('options') + ->insert(['option_name' => $key, 'option_value' => $this[$key]]); + } else { + DB::table('options') + ->where('option_name', $key) + ->update(['option_value' => $this[$key]]); + } } } diff --git a/setup/update.php b/setup/update.php index 19286f36..7f826012 100644 --- a/setup/update.php +++ b/setup/update.php @@ -36,6 +36,11 @@ switch ($step) { } closedir($resource); + foreach (config('options') as $key => $value) { + if (!Option::has($key)) + Option::set($key, $value); + } + if (!$update_script_exist) { // if update script is not given Option::set('version', config('app.version')); diff --git a/setup/update_scripts/update-3.0.1-to-3.0.2.php b/setup/update_scripts/update-3.0.1-to-3.0.2.php index 1beaed9d..cf579694 100644 --- a/setup/update_scripts/update-3.0.1-to-3.0.2.php +++ b/setup/update_scripts/update-3.0.1-to-3.0.2.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-08-11 13:08:13 * @Last Modified by: printempw - * @Last Modified time: 2016-08-11 13:25:23 + * @Last Modified time: 2016-08-29 13:47:13 */ $options = [ @@ -14,7 +14,7 @@ $options = [ ]; foreach ($options as $key => $value) { - Option::add($key, $value); + Option::set($key, $value); } Option::set('version', '3.0.2');