Beispiel #1
0
 /**
  * 显示课程检索表单
  * @author FuRongxin
  * @date    2016-02-23
  * @version 2.0
  * @param   \Illuminate\Http\Request $request 检索请求
  * @return  \Illuminate\Http\Response 课程检索框
  */
 public function showSearchForm(Request $request)
 {
     $inputs = $request->all();
     $search = isset($inputs['searched']) ? $inputs['searched'] : false;
     $grade = isset($inputs['nj']) ? $inputs['nj'] : 'all';
     $college = isset($inputs['xy']) ? $inputs['xy'] : 'all';
     $major = isset($inputs['zy']) ? $inputs['zy'] : 'all';
     $keyword = isset($inputs['keyword']) ? $inputs['keyword'] : '';
     $type = isset($inputs['type']) ? $inputs['type'] : '';
     $campuses = Campus::all()->each(function ($campus) {
         if (empty($campus->dm)) {
             $campus->dm = 'unknown';
             $campus->mc = '未知';
         }
     });
     $grades = Mjcourse::whereNd(session('year'))->whereXq(session('term'))->where('nj', '<>', '')->select('nj')->distinct()->orderBy('nj')->get();
     $colleges = Department::colleges()->where('mc', '<>', '')->select('dw', 'mc')->orderBy('dw')->get();
     $majors = Major::whereZt(config('constants.status.enable'))->where('mc', '<>', '')->select('zy', 'mc', 'xy')->orderBy('zy')->get();
     return view('selcourse.search')->withTitle('课程检索')->withInfo('请输入课程序号或课程中文名称进行检索')->withCampuses($campuses)->withGrades($grades)->withColleges($colleges)->withMajors($majors)->withSearch($search)->withSgrade($grade)->withScollege($college)->withSmajor($major)->withKeyword($keyword)->withType($type);
 }