where($where) ->order("od asc,recommend desc,gr_id desc") ->paginate($pageSize, false, ['page' => $page]); $result = ['grlist' => $grlist->items(), 'total' => $grlist->total()]; return app('json')->success($result); } /** * 获取轮播列表 * @return mixed */ public function recommend() { $EducationModel = new \app\model\api\Education(); $where = [ 'audit' => 1, 'recommend' => 1, ]; $recommendList = $EducationModel->getEducationGrList($where, 9, "od asc,recommend desc,gr_id desc"); $result = ['recommendList' => $recommendList]; return app('json')->success($result); } /** * 获取课程组列表 * @return mixed */ public function getCourseList() { $where['audit'] = 1; $type1 = input('type', ''); if ($type1 !== '') { $where['type1'] = $type1; } $grlist = \app\model\api\Education::where($where) ->limit(20) ->order('od asc,recommend desc,gr_id desc') ->select() ->toArray(); foreach ($grlist as &$v) { $count = EducationCourse::where('course_status', 1) ->where('gr_id', $v['gr_id']) ->where('course_audit', 1) ->field('count(*) as count,sum(course_play_count) as alll') ->find(); $v['count'] = $count['count']; $count['alll'] += $v['times']; $v['alll'] = $count['alll'] ? $count['alll'] : 0; } return app('json')->success(['data' => $grlist]); } }