public function homepageInfo($page = 'index') { $pagedata = new PrintController(); $data = $pagedata->pagedata($page); $data_final = $data; $classify = new Classify(); foreach ($data as $k => $v) { if ($v['type'] == 'list') { $type_arr = array(1, 2, 3); $list = Classify::where('cus_id', '=', $pagedata->cus_id)->whereIn('type', array(1, 2, 3, 4, 5, 6))->where('pc_show', '=', 1)->get()->toArray(); $value = array(); $selected = false; foreach ($list as $key => $l) { $value[$key]['id'] = $l['id']; $value[$key]['name'] = $l['name']; $value[$key]['p_id'] = $l['p_id']; $value[$key]['type'] = $l['type']; if (isset($v['config']['id']) && $l['id'] == $v['config']['id']) { $value[$key]['selected'] = 1; $selected = true; } else { $value[$key]['selected'] = 0; } } if (isset($v['config']['filter'])) { if ($v['config']['filter'] == 'page') { $value = $classify->toTree($value); $type_arr = array(4); } elseif ($v['config']['filter'] == 'list') { $value = $classify->toTree($value); $type_arr = array(1, 2, 3); } elseif ($v['config']['filter'] == 'feedback') { $value = $classify->toTree($value); $type_arr = array(5); } elseif ($v['config']['filter'] == 'ALL') { $value = $classify->toTree($value); $type_arr = array(1, 2, 3, 4, 5, 6); } else { $value = $classify->toTree($value); $type_arr = array(1, 2, 3, 4); } } $this->unsetFalseClassify($value, $type_arr); if (!$selected && count($value)) { foreach ($value as $key => $v) { $value[$key]['selected'] = 1; break; } } if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) { $this->unsetLastClassify($value); } $data_final[$k]['config']['list'] = $value; if (isset($v['config']['star_only'])) { $data_final[$k]['config']['star_only'] = $v['config']['star_only']; } else { $data_final[$k]['config']['star_only'] = "0"; } } elseif ($v['type'] == 'page') { $list = Classify::where('cus_id', '=', $pagedata->cus_id)->where('type', 4)->where('pc_show', '=', 1)->get()->toArray(); $value = array(); $selected = false; foreach ($list as $key => $l) { $value[$key]['id'] = $l['id']; $value[$key]['name'] = $l['name']; $value[$key]['p_id'] = $l['p_id']; $value[$key]['type'] = $l['type']; if (isset($v['config']['id']) && $l['id'] == $v['config']['id']) { $value[$key]['selected'] = "1"; $selected = true; } else { $value[$key]['selected'] = "0"; } } if (!$selected) { $value[0]['selected'] = 1; } if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) { $this->unsetLastClassify($value); } $data_final[$k]['config']['list'] = $value; if (isset($v['config']['star_only'])) { $data_final[$k]['config']['star_only'] = $v['config']['star_only']; } else { $data_final[$k]['config']['star_only'] = "0"; } } elseif ($v['type'] == 'navs') { $type_arr = array(1, 2, 3, 4, 6); $list = Classify::where('cus_id', '=', $pagedata->cus_id)->whereIn('type', array(1, 2, 3, 4, 6))->where('pc_show', '=', 1)->get()->toArray(); $value = array(); $selected = false; foreach ($list as $key => $l) { $value[$key]['id'] = $l['id']; $value[$key]['name'] = $l['name']; $value[$key]['p_id'] = $l['p_id']; $value[$key]['type'] = $l['type']; if (isset($v['config']['id']) && $l['id'] == $v['config']['id']) { $value[$key]['selected'] = 1; $selected = true; } else { $value[$key]['selected'] = 0; } } if (isset($v['config']['filter'])) { if ($v['config']['filter'] == 'page') { $value = $classify->toTree($value); $type_arr = array(4); } elseif ($v['config']['filter'] == 'list') { $value = $classify->toTree($value); $type_arr = array(1, 2, 3); } elseif ($v['config']['filter'] == 'ALL') { $value = $classify->toTree($value); $type_arr = array(1, 2, 3, 4, 6); } else { $value = $classify->toTree($value); $type_arr = array(1, 2, 3, 4); } } $this->unsetFalseClassify($value, $type_arr); if (!$selected && count($value)) { foreach ($value as $key => $v) { $value[$key]['selected'] = 1; break; } } if (isset($v['config']['mustchild']) && $v['config']['mustchild'] == true) { $this->unsetLastClassify($value); } $data_final[$k]['config']['list'] = $value; if (isset($v['config']['star_only'])) { $data_final[$k]['config']['star_only'] = $v['config']['star_only']; } else { $data_final[$k]['config']['star_only'] = "0"; } } } //dd($data_final); return $data_final; }