/** * Manage settings action * @param Request $request * @param string $section_id Section name * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View * @throws \FlashSale\Http\Modules\Admin\Models\Exception * @since 07-01-2016 * @author Dinanath Thakur <*****@*****.**> */ public function manageSettings(Request $request, $section_id) { $time_start = microtime(true); $objSettingsObject = SettingsObject::getInstance(); $objSettingsSection = SettingsSection::getInstance(); if ($request->isMethod('post')) { $inputData = $request->input('update'); if (isset($inputData) && !empty($inputData)) { try { $updateFlag = false; foreach ($inputData as $objectId => $value) { $whereForUpdate = ['rawQuery' => 'object_id =?', 'bindParams' => [$objectId]]; if (is_array($value)) { $tempValue = '#M#'; foreach ($value as $checkBoxKey => $checkBoxValue) { if ($checkBoxValue == 'on') { $tempValue .= $checkBoxKey . '=Y&'; } } $tempValue = rtrim($tempValue, '&'); $updateData['value'] = $tempValue; } else { $updateData['value'] = $value == 'on' ? 'Y' : $value; } $updatedObjectResult = $objSettingsObject->updateObjectWhere($updateData, $whereForUpdate); if ($updatedObjectResult) { $updateFlag = true; } $whereForUpdate = $updateData = ''; } return Redirect::back()->with($updateFlag ? ['status' => 'success', 'msg' => 'Your changes have been saved.'] : ['status' => 'info', 'msg' => 'Nothing to update.']); } catch (\Exception $e) { return Redirect::back()->with(['status' => 'error', 'msg' => 'Sorry, an error occurred. Please reload the page and try again.']); } } } $whereForSetting = ['rawQuery' => 'parent_id =? AND type =? AND status =?', 'bindParams' => [0, 'CORE', 1]]; $allSection = $objSettingsSection->getAllSectionWhere($whereForSetting); $whereForSetting = ['rawQuery' => 'settings_sections.name =? AND settings_descriptions.object_type=? AND settings_descriptions.status=? AND settings_objects.status=?', 'bindParams' => [$section_id, 'O', 1, 1]]; $allObjectsOfSection = $objSettingsObject->getAllObjectsAndVariantsOfASectionWhere($whereForSetting); // die("Execution time in sec: " . (microtime(true) - $time_start)); return view('Admin/Views/setting/manageSettings', ['allObjectsOfSection' => $allObjectsOfSection, 'allSection' => $allSection]); }
public static function getSettingsSection() { $objSettingsSection = SettingsSection::getInstance(); $whereForSetting = ['rawQuery' => 'parent_id =? AND type =? AND status =?', 'bindParams' => [0, 'CORE', 1]]; $allSections = $objSettingsSection->getAllSectionWhere($whereForSetting); return $allSections; }