public function homepageModify()
 {
     $cus_id = Auth::id();
     $template_id = websiteInfo::where('cus_id', $cus_id)->pluck('pc_tpl_id');
     $website_config = new WebsiteConfig();
     $website_config->cus_id = $cus_id;
     $page = Input::get('page');
     $website_config->key = $page;
     $count = $website_config->where('cus_id', $cus_id)->where('template_id', $template_id)->where('key', $page)->count();
     $website_config->template_id = $template_id;
     $data = Input::get('data');
     /*
             if(isset($data['slidepics']) && count($data['slidepics'])){
        foreach($data['slidepics'] as &$arr){
            $arr['link']=$arr['href'];
            $arr['image']=basename($arr['src']);
            unset($arr['href']);
            unset($arr['src']);
        }
             }
     */
     foreach ($data as $key => $val) {
         if (is_array($data[$key]) && count($data[$key])) {
             if (array_key_exists("href", $data[$key]) || array_key_exists("src", $data[$key])) {
                 $data[$key]['link'] = $data[$key]['href'];
                 $data[$key]['image'] = basename($data[$key]['src']);
                 unset($data[$key]['href']);
                 unset($data[$key]['src']);
             } else {
                 foreach ($data[$key] as &$arr) {
                     if (is_array($arr)) {
                         if (array_key_exists("href", $arr) || array_key_exists("src", $arr)) {
                             $arr['link'] = $arr['href'];
                             $arr['image'] = basename($arr['src']);
                             unset($arr['href']);
                             unset($arr['src']);
                         }
                     }
                 }
             }
         }
         $temp_arr = $data[$key];
         unset($data[$key]);
         $data[$key]['value'] = $temp_arr;
     }
     $website_config->value = serialize($data);
     if ($count) {
         $result = $website_config->where('cus_id', $cus_id)->where('template_id', $template_id)->where('key', $page)->update(['value' => $website_config->value]);
     } else {
         $result = $website_config->save();
     }
     if ($result) {
         return Response::json(['err' => 0, 'msg' => '', 'data' => null]);
     } else {
         return Response::json(['err' => 1001, 'msg' => '数据保存失败', 'data' => null]);
     }
 }
Beispiel #2
0
 public function quickBarJsonModify()
 {
     $cus_id = Auth::id();
     $org_img = '';
     $vx_bar_img = '';
     $data = Input::get('QuickBar');
     $QuickBar = serialize($data);
     foreach ((array) $data as $v) {
         if ($v['for'] === 'vx_barcode') {
             $vx_bar_img = basename($v['data']);
         }
     }
     $websiteconfig = WebsiteConfig::where('cus_id', $cus_id)->where('type', 2)->where('template_id', '0')->where('key', 'quickbar')->pluck('value');
     foreach ((array) unserialize($websiteconfig) as $v) {
         if ($v['for'] === 'vx_barcode') {
             $org_img = basename($v['data']);
         }
     }
     $id = WebsiteConfig::where('cus_id', $cus_id)->where('type', 2)->where('template_id', '0')->where('key', 'quickbar')->pluck('id');
     if ($id) {
         $QuickData = WebsiteConfig::find($id);
     } else {
         $QuickData = new WebsiteConfig();
         $QuickData->cus_id = $cus_id;
         $QuickData->type = 2;
         $QuickData->template_id = 0;
         $QuickData->key = 'quickbar';
     }
     $QuickData->pushed = 1;
     $QuickData->value = $QuickBar;
     $result = $QuickData->save();
     if ($result) {
         if ($org_img != $vx_bar_img) {
             $imgdel = new ImgDel();
             $imgdel->mysave($org_img, 'common');
         }
         $json_result = ['err' => 0, 'msg' => '保存成功'];
     } else {
         $json_result = ['err' => 1001, 'msg' => '该栏目存在文章,需转移才能创建子栏目', 'data' => []];
     }
     return Response::Json($json_result);
 }