/**
  * Get all objects and their related variants for a section
  * @param $where
  * @param array $selectedColumns
  * @return mixed
  * @throws Exception
  * @since 08-01-2016
  * @author Dinanath Thakur <*****@*****.**>
  */
 public function getAllObjectsAndVariantsOfASectionWhere($where, $selectedColumns = ['*'])
 {
     if (func_num_args() > 0) {
         $where = func_get_arg(0);
         $cacheKey = $this->table . "::" . implode('-', array_flatten($where));
         if (cacheGet($cacheKey)) {
             return cacheGet($cacheKey);
         }
         //            die("no cache");
         DB::statement('SET SESSION group_concat_max_len = 10000');
         $result = DB::table($this->table)->join('settings_sections', 'settings_sections.section_id', '=', 'settings_objects.section_id')->join('settings_descriptions', 'settings_descriptions.object_id', '=', 'settings_objects.object_id')->leftJoin('settings_variants', 'settings_variants.object_id', '=', 'settings_objects.object_id')->leftJoin('settings_descriptions as sd', function ($join) {
             $join->on('sd.object_id', '=', 'settings_variants.variant_id');
         })->whereRaw($where['rawQuery'], isset($where['bindParams']) ? $where['bindParams'] : array())->select(DB::raw('settings_objects.object_id ,
             settings_objects.*,
             settings_sections.name AS section_name,
             settings_descriptions.value AS setting_name,
             settings_descriptions.tooltip,
             GROUP_CONCAT(DISTINCT(settings_variants.variant_id) ORDER BY settings_variants.position) AS variant_ids,
             GROUP_CONCAT(DISTINCT(BINARY settings_variants.name)  ORDER BY settings_variants.position  SEPARATOR "____") AS variant_names,
             GROUP_CONCAT(CASE sd.object_type WHEN "V" THEN sd.value END  ORDER BY settings_variants.position SEPARATOR "____") AS var_names'))->orderBy('settings_objects.position')->groupBy('settings_objects.object_id')->get();
         cachePut($cacheKey, $result, $this->minutes);
         return $result;
     } else {
         throw new Exception('Argument Not Passed');
     }
 }
 /**
  * Get all variant details
  * @param $where
  * @param array $selectedColumns
  * @return array|bool|object
  * @throws Exception
  * @since 06-01-2016
  * @author Dinanath Thakur <*****@*****.**>
  */
 public function getAllVariantWhere($where, $selectedColumns = ['*'])
 {
     if (func_num_args() > 0) {
         $where = func_get_arg(0);
         $cacheKey = $this->table . "::" . implode('-', array_flatten($where));
         if (cacheGet($cacheKey)) {
             return cacheGet($cacheKey);
         }
         $result = DB::table($this->table)->whereRaw($where['rawQuery'], isset($where['bindParams']) ? $where['bindParams'] : array())->select($selectedColumns)->get();
         cachePut($cacheKey, $result, $this->minutes);
         return $result;
     } else {
         throw new Exception('Argument Not Passed');
     }
 }
コード例 #3
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;
 }