mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
deprecate Option::save()
This commit is contained in:
parent
098d0ed7b8
commit
59d7a9c4c2
@ -27,6 +27,7 @@ class SaveOptionRepository
|
||||
*/
|
||||
public function terminate($request, $response)
|
||||
{
|
||||
app('options')->save();
|
||||
// deprecated
|
||||
// app('options')->save();
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ class OptionForm
|
||||
protected function getValueById($id)
|
||||
{
|
||||
if (false === ($result = $this->parseIdWithOffset($id))) {
|
||||
return Arr::get($this->values, $id, option($id, null, false));
|
||||
return Arr::get($this->values, $id, option($id));
|
||||
} else {
|
||||
$option = Arr::get(
|
||||
$this->values,
|
||||
@ -268,10 +268,6 @@ class OptionForm
|
||||
*/
|
||||
protected function assignValues()
|
||||
{
|
||||
if (!is_null($this->alwaysCallback)) {
|
||||
call_user_func($this->alwaysCallback, $this);
|
||||
}
|
||||
|
||||
// load values for items if not set manually
|
||||
foreach ($this->items as $item) {
|
||||
if ($item instanceof OptionFormGroup) {
|
||||
@ -310,6 +306,10 @@ class OptionForm
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
if (!is_null($this->alwaysCallback)) {
|
||||
call_user_func($this->alwaysCallback, $this);
|
||||
}
|
||||
|
||||
$this->assignValues();
|
||||
|
||||
return view('vendor.option-form.main')->with(array_merge(get_object_vars($this)))->render();
|
||||
|
@ -64,11 +64,54 @@ class OptionRepository extends Repository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given option value.
|
||||
*
|
||||
* @param array|string $key
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function set($key, $value = null)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
// If given key is an array
|
||||
foreach ($key as $innerKey => $innerValue) {
|
||||
Arr::set($this->items, $innerKey, $innerValue);
|
||||
$this->doSetOption($innerKey, $innerValue);
|
||||
}
|
||||
} else {
|
||||
Arr::set($this->items, $key, $value);
|
||||
$this->doSetOption($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do really save modified options to database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function doSetOption($key, $value)
|
||||
{
|
||||
try {
|
||||
if (!DB::table('options')->where('option_name', $key)->first()) {
|
||||
DB::table('options')
|
||||
->insert(['option_name' => $key, 'option_value' => $value]);
|
||||
} else {
|
||||
DB::table('options')
|
||||
->where('option_name', $key)
|
||||
->update(['option_value' => $value]);
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do really save modified options to database.
|
||||
*
|
||||
* @deprecated
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
$this->itemsModified = array_unique($this->itemsModified);
|
||||
|
@ -45,7 +45,7 @@ class Repository implements ArrayAccess // Illuminate\Contracts\Cache\Repository
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given option value.
|
||||
* Set a given item value.
|
||||
*
|
||||
* @param array|string $key
|
||||
* @param mixed $value
|
||||
|
Loading…
Reference in New Issue
Block a user