/** * Handle the event. * * @param Login $event * @return void */ public function handle(Login $event) { if (!Fresh::whereXh(Auth::user()->xh)->exists()) { if (!Profile::whereXh(Auth::user()->xh)->whereXjzt(config('constants.school.student'))->exists()) { Auth::logout(); return back()->withInput()->withStatus('不是在校生,请不要登录系统'); } } session(['year' => Setting::find('XK_ND')->value, 'term' => Setting::find('XK_XQ')->value, 'campus' => Auth::user()->profile->college->pivot->xq, 'season' => Auth::user()->profile->zsjj, 'grade' => Auth::user()->profile->nj, 'major' => Auth::user()->profile->zy]); $log = new Slog(); $log->ip = request()->ip(); $log->czlx = 'login'; $log->save(); }
/** * Bootstrap any application services. * * @return void */ public function boot() { view()->composer('app', function ($view) { // 是否新生 if ($is_fresh = Fresh::whereXh(Auth::user()->xh)->exists()) { $user = Fresh::find(Auth::user()->xh); } // 是否在校生 if ($is_student = Profile::whereXh(Auth::user()->xh)->whereXjzt(config('constants.school.student'))->exists()) { $user = Profile::find(Auth::user()->xh); } // 是否新入校未足一年的学生 $is_newer = Profile::isFresh(Auth::user())->exists(); // 是否允许选课 $allowed_select = Setting::find('XK_KG')->value; // 是否允许选通识素质课 $allowed_general = Setting::find('XK_TS')->value; // 是否允许选其他课程 $allowed_others = Setting::find('XK_QT')->value; // 是否允许公体选课 $allowed_pubsport = Setting::find('XK_GT')->value; $view->withIsFresh($is_fresh)->withIsStudent($is_student)->withUser($user)->withIsNewer($is_newer)->withAllowedSelect($allowed_select)->withAllowedGeneral($allowed_general)->withAllowedOthers($allowed_others)->withAllowedPubsport($allowed_pubsport); }); }
/** * 显示可选课程列表 * @author FuRongxin * @date 2016-02-23 * @version 2.0 * @param string $type 课程类型 * @return \Illuminate\Http\Response 可选课程列表 */ public function show($type) { if ('pubsport' == $type) { if (config('constants.status.disable') == Setting::find('XK_GT')->value) { abort(403, '现在未开放公体选课,不允许公体选课'); } } elseif (config('constants.status.disable') == Setting::find('XK_KG')->value) { abort(403, '现在未开放选课,不允许选课'); } if (Unpaid::whereXh(Auth::user()->xh)->exists()) { abort(403, '请交清费用再进行选课'); } if ('pubsport' != $type) { if (config('constants.status.enable') == Setting::find('XK_SJXZ')->value) { $profile = Profile::whereXh(Auth::user()->xh)->select('nj', 'xz')->firstOrFail(); // 未在时间限制表中配置,默认不允许选课 $now = Carbon::now(); $exists = Lmttime::whereNj($profile->nj)->whereXz($profile->xz)->where('kssj', '<', $now)->where('jssj', '>', $now)->exists(); if (!$exists) { abort(403, '现在未到选课时间,不允许选课'); } } } if (in_array($type, array_keys(config('constants.course.general')))) { if (config('constants.stauts.disable') == Setting::find('XK_TS')->value) { abort(403, '现在未开放通识素质课选课,不允许选课'); } if (config('constants.status.enable') == Setting::find('XK_TSXZ')->value) { $profile = Profile::whereXh(Auth::user()->xh)->select('nj', 'xz')->firstOrFail(); // 未在时间限制表中配置,默认不允许选通识素质课 $now = Carbon::now(); $exists = Lmtgeneral::whereNj($profile->nj)->whereXz($profile->xz)->where('kssj', '<', $now)->where('jssj', '>', $now)->exists(); if (!$exists) { abort(403, '现在未到通识素质课选课时间,不允许选课'); } } $type_name = config('constants.course.general.' . $type . '.name'); } $type_name = isset($type_name) ? $type_name : config('constants.course.' . $type . '.name'); $campuses = Campus::all()->each(function ($course) { if (empty($course->dm)) { $course->dm = 'unknown'; $course->mc = '未知'; } }); return view('selcourse.show')->withTitle($type_name . '选课表')->withType($type)->withCampuses($campuses); }