public function enrollSection() { $sectionCode = SectionCode::where('code', Input::get('code'))->first(); if (isset($sectionCode->_id)) { $section = Subject::find($sectionCode->subject_id)->sections()->find($sectionCode->section_id); $message = ""; if (strcasecmp($section->current_code, $sectionCode->code) === 0) { $codes = SectionCode::where('code', Input::get('code'))->whereIn('students_id', array(Auth::id()))->first(); if (!isset($codes->_id)) { $pending = new PendingEnrollment(); $pending->section_code_id = new MongoId($sectionCode->_id); $pending->student_id = Auth::id(); $pending->teacher_id = new MongoId($sectionCode->teacher_id); try { $pending->save(); } catch (MongoDuplicateKeyException $e) { return Redirect::back()->withErrors(array('error' => Lang::get('register_group.enroll_pending'))); } return Redirect::to(Lang::get('routes.enroll_section'))->with('message', Lang::get('register_group.enroll_sucess')); } else { $message = Lang::get('register_group.user_register'); } } else { $message = Lang::get('register_group.code_expired'); } } else { $message = Lang::get('register_group.code_fail'); } return Redirect::back()->withErrors(array('error' => $message)); }
/** * Return the stats message for a User * * @return Array(Stats) */ public static function getStats() { $messages = UserController::getUser(Auth::user())->messages(); $inbox = $messages->where('from', '!=', Auth::id())->where('archived', false)->count(); $sent = $messages->where('from', Auth::id())->where('archived', false)->count(); $archived = $messages->where('archived', true)->count(); return array('inbox' => $inbox, 'unread' => count(MessageController::unReadMessages("all")), 'sent' => $sent, 'archived' => $archived, 'approve' => PendingEnrollment::where('teacher_id', Auth::id())->count(), 'join' => PendingGroup::where('teamleader_id', Auth::id())->count()); }
public function showApprovalStudentView() { $pending = PendingEnrollment::where('teacher_id', Auth::id())->get(); if (count($pending) > 0) { return View::make('teacher.approval_student')->with(array('pending' => $pending, 'stats' => MessageController::getStats())); } else { return Redirect::to(Lang::get('routes.' . Auth::user()->rank)); } }