public function find() { if (Request::ajax()) { if (!is_null(Input::get('group_id'))) { $group = Group::find(Input::get('group_id')); if (isset($group->_id)) { return Response::json($group); } else { return Response::json(""); } } else { if (!is_null(Input::get('section_code'))) { $section_code = SectionCode::where('code', Input::get('section_code'))->first(); $groups = Group::where('section_code_id', new MongoId($section_code->_id))->get(); return Response::json($groups); } else { $pending = PendingGroup::where('student_id', Auth::id())->get(); $array = array(); foreach ($pending as $value) { array_push($array, $value->group_id); } $groups = Group::where('section_code_id', new MongoId(Input::get('section_code')))->whereNotIn('students_id', array(Auth::id()))->whereNotIn('_id', $array)->get(); if (count($groups) > 0) { return Response::json(array('groups' => $groups)); } else { return Response::json(""); } } } } }
public function approve() { if (Request::ajax()) { $pending = PendingGroup::find(Input::get('id')); Group::find($pending->group_id)->push('students_id', $pending->student_id, true); $pending->delete(); return Response::json(array('code' => "00", 'stats' => MessageController::getStats())); } }
/** * 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 showApprovalGroupView() { $pending = PendingGroup::where('teamleader_id', Auth::id())->get(); if (count($pending) > 0) { return View::make('student.approval_group')->with(array('pending' => $pending, 'stats' => MessageController::getStats())); } else { return Redirect::to(Lang::get('routes.' . Auth::user()->rank)); } }