public function save()
{
$this->itemsModified = array_unique($this->itemsModified);
try {
foreach ($this->itemsModified as $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]]);
}
}
// clear the list
$this->itemsModified = [];
} catch (QueryException $e) {
return;
}
}
/** * Persist the currently enabled plugins. * * @param array $enabled */ protected function setEnabled(array $enabled) { $enabled = array_values(array_unique($enabled)); $this->option->set('plugins_enabled', json_encode($enabled)); // ensure to save options $this->option->save(); }