enhance Option class
This commit is contained in:
parent
f7fd47f2d6
commit
fc4b64ca34
@ -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]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'));
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user