/**
  * 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]);
 }
コード例 #2
0
 /**
  * Get setting value and cache the value for a day
  * @param string $settingObject
  * @return mixed
  * @throws Exception
  * @since 19-01-2016
  * @author Dinanath Thakur <*****@*****.**>
  */
 function getSetting($settingObject)
 {
     switch ($settingObject) {
         case 'price_symbol':
             $objCurrencyModel = \FlashSale\Http\Modules\Admin\Models\Currency::getInstance();
             $whereForPrice = ['rawQuery' => 'is_primary=? AND status=?', 'bindParams' => ['Y', 1]];
             $selectedColumns = ['symbol'];
             $cacheKey = "settings_objects::" . implode('-', array_flatten($whereForPrice));
             if (cacheGet($cacheKey)) {
                 $priceSymbol = cacheGet($cacheKey);
             } else {
                 $priceSymbol = $objCurrencyModel->getCurrencyWhere($whereForPrice, $selectedColumns);
                 cachePut($cacheKey, $priceSymbol, 86400);
             }
             $settingValue = $priceSymbol->symbol;
             break;
         default:
             $objSettingObject = \FlashSale\Http\Modules\Admin\Models\SettingsObject::getInstance();
             $whereForSettingObject = ['rawQuery' => 'name=?', 'bindParams' => [$settingObject]];
             $selectedColumns = ['value'];
             $cacheKey = "settings_objects::" . implode('-', array_flatten($whereForSettingObject));
             if (cacheGet($cacheKey)) {
                 $settingValue = cacheGet($cacheKey);
             } else {
                 $settingValue = $objSettingObject->getSettingObjectWhere($whereForSettingObject, $selectedColumns);
                 cachePut($cacheKey, $settingValue, 86400);
             }
             $settingValue = $settingValue->value;
             break;
     }
     return $settingValue;
 }
コード例 #3
0
 /**
  * Get setting value
  * @param string $settingObject
  * @return mixed
  * @throws Exception
  * @since 19-01-2016
  * @author Dinanath Thakur <*****@*****.**>
  */
 function getSetting($settingObject)
 {
     switch ($settingObject) {
         case 'price_symbol':
             $objCurrencyModel = \FlashSale\Http\Modules\Admin\Models\Currency::getInstance();
             $whereForPrice = ['rawQuery' => 'is_primary=? AND status=?', 'bindParams' => ['Y', 1]];
             $selectedColumns = ['symbol'];
             $priceSymbol = $objCurrencyModel->getCurrencyWhere($whereForPrice, $selectedColumns);
             $settingValue = $priceSymbol->symbol;
             break;
         default:
             $objSettingObject = \FlashSale\Http\Modules\Admin\Models\SettingsObject::getInstance();
             $whereForSettingObject = ['rawQuery' => 'name=?', 'bindParams' => [$settingObject]];
             $selectedColumns = ['value'];
             $settingValue = $objSettingObject->getSettingObjectWhere($whereForSettingObject, $selectedColumns);
             $settingValue = $settingValue->value;
             break;
     }
     return $settingValue;
 }