/** * 选课门数和人数限制检测 * 2016-06-16:添加专业号检测 * 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式 * @author FuRongxin * @date 2016-09-01 * @version 2.1.2 * @param string $type 课程类型 * @param string $kcxh 12位课程序号 * @param string $zy 专业号 * @param integer $ms 课程门数限制,-1为无限制 * @param integer $rs 选课人数限制,-1为无限制 * @return array 课程门数和人数限制标志数组,true为超限,false为未超限 */ public function checkcourse($type, $kcxh, $zy, $ms = -1, $rs = -1) { $limits = ['ms' => false, 'rs' => false]; if (in_array($type, array_keys(config('constants.course.general')))) { if (-1 < $ms) { $count = Selcourse::ofType($type)->whereNd(session('year'))->whereXq(session('term'))->whereXh(Auth::user()->xh)->count(); if ($count >= $ms) { $limits['ms'] = true; } } if (-1 < $rs) { $course = Count::whereKcxh($kcxh)->whereZy($zy)->first(); $count = isset($course) ? $course->rs : 0; if ($count >= $rs) { $limits['rs'] = true; } } } else { // 2016-09-01:应教务处要求添加公体选课统计,修改选课统计方式 if (Helper::isCourseType($kcxh, config('constants.course.pubsport.type'))) { $course = Count::whereKcxh($kcxh)->first(); } else { $course = Count::whereKcxh($kcxh)->whereZy($zy)->first(); } $count = isset($course) ? $course->rs : 0; if ($count >= $rs) { $limits['rs'] = true; } } return request()->ajax() ? response()->json($limits) : $limits; }