/** * 公司真题 */ public function getIndex() { //只显示职业方向和公司分类 $cate_info = Category::where('cate_name', '职业方向')->orwhere('cate_name', '公司')->select(['_id', 'cate_name'])->get(); foreach ($cate_info as $k => &$val) { $tmp_cate = Category::where('pid', (string) $val->_id)->select(['_id', 'cate_name'])->get(); $val['two_cate'] = $tmp_cate; } //搜索最近5年的 $datetime['title'] = '时间'; for ($i = date("Y"); $i > date("Y") - 5; $i--) { $datetime['times'][] = $i; } //默认显示最新 $url = array(); //分页路径 if (!empty($_GET['is_hot'])) { $id = $_GET['is_hot']; $where['is_hot'] = '1'; $url['is_hot'] = 1; } else { $id = ''; $where['is_news'] = '1'; } //搜索 $choose_cate = array(); $par = array(); if (!empty($_GET['par'])) { $par = explode('_', $_GET['par']); $url['par'] = $_GET['par']; $choose_cate = Category::whereIn('_id', $par)->select(['_id', 'cate_name'])->get(); $exam_info = Exam::whereIn('job', $par)->orwhereIn('company_id', $par)->where($where)->paginate(3); } else { $exam_info = Exam::where($where)->paginate(3); } //查询公司logo foreach ($exam_info as $k => &$val) { $company_info = Category::where('_id', $val->company_id)->select(['logo'])->first(); $val->company_logo = $company_info->logo; } $exam_info->setPath('index'); return view('question.c_exam', ['exam_info' => $exam_info, 'cate_info' => $cate_info, 'choose_cate' => $choose_cate, 'datetime' => $datetime, 'id' => $id, 'par' => $par, 'url' => $url]); }
/** * 试题广场 */ public function getIndex() { //只显示职业方向和公司分类 $cate_info = Category::where('pid', '0')->select(['_id', 'cate_name'])->get(); foreach ($cate_info as $k => &$val) { if ($val->cate_name == '知识点') { $tmp_cate = Category::where('pid', (string) $val->_id)->where('level', '2')->select(['_id', 'cate_name'])->get(); $val['two_cate'] = $tmp_cate; foreach ($tmp_cate as $kk => &$vv) { $tmp_zhishi = Category::where('pid', (string) $vv->_id)->select(['_id', 'cate_name'])->get(); $vv['zhishi'] = $tmp_zhishi; } } else { $tmp_cate = Category::where('pid', (string) $val->_id)->select(['_id', 'cate_name'])->get(); $val['two_cate'] = $tmp_cate; } } //print_R($cate_info);die; $url = array(); //默认显示最新 if (!empty($_GET['is_hot'])) { $id = $_GET['is_hot']; $where['is_hot'] = '1'; $url['is_hot'] = '1'; } else { $id = ''; $where['is_news'] = '1'; } //搜索 $choose_cate = array(); $par = array(); $par_arr = array(); $q_type = array(); if (!empty($_GET['par'])) { $par = explode('_', $_GET['par']); $par_arr = $par; $url['par'] = $_GET['par']; $choose_cate = Category::whereIn('_id', $par)->orwhereIn('cate_name', $par)->select(['_id', 'cate_name'])->get(); foreach ($par as $k => $v) { $reg = "/^[\\x{4e00}-\\x{9fa5}]+\$/u"; $res = preg_match($reg, $v); if ($res) { $q_type[] = $par[$k]; unset($par[$k]); } } if ($par) { $exam_info = Exam::whereIn('job', $par)->orwhereIn('company_id', $par)->orwhereIn('zhishi', $par)->where($where)->get(); } else { $exam_info = Exam::where($where)->get(); } } else { $exam_info = Exam::where($where)->get(); } $id_arr = array(); foreach ($exam_info as $k => $val) { $id_arr[] = $val->_id; } if (!$q_type) { $question_info = Question::whereIn('e_id', $id_arr)->select(['q_title'])->paginate(10); } else { $question_info = Question::whereIn('e_id', $id_arr)->whereIn('q_type', $q_type)->select(['q_title'])->paginate(10); } //print_R($question_info); $question_info->setPath('index'); return view('square.square', ['cate_info' => $cate_info, 'question_info' => $question_info, 'id' => $id, 'choose_cate' => $choose_cate, 'par_arr' => $par_arr, 'url' => $url]); }