public function more() { $user = User::with('Course', 'Gender', 'userType')->where('StudentID', Auth::user()->StudentID)->first(); $adminGroupPages = GroupPage::where('StudentID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); $groupPages = GroupPageMember::with('groupPages')->where('StudentID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); if (Auth::user()->UserTypeID == 2) { $files = Files::where('delFlag', 0)->where('folderID', 0)->where('OwnerID', Auth::user()->StudentID)->get(); $fileFolders = FilesFolder::where('OwnerID', Auth::user()->StudentID)->where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); $activities = GroupPageActivity::where('OwnerID', Auth::user()->StudentID)->where('delFlag', 0)->get(); $quizzes = Quiz::where('delFlag', 0)->orderBy('created_at', 'DESC')->get(); } else { $activities = GroupPageActivityGroup::with('groupPage', 'groupPageActivityFiles')->where('deadline', '>', date('Y-m-d H:i:s'))->whereExists(function ($q) { $q->select(DB::raw(0))->from('grouppagemember')->whereRaw('grouppagemember.grouppageID = grouppageactivitygroup.grouppageID')->where('StudentID', Auth::user()->StudentID)->whereRaw('grouppagemember.delFlag = 0'); })->orderBy('deadline', 'ASC')->get(); $quizzes = QuizGroupPage::with('groupPageMember', 'groupPage', 'quiz')->where('delFlag', 0)->whereNotExists(function ($q) { $q->select(DB::raw(0))->from('quiztaken', 'grouppagemember')->where('quiztaken.OwnerID', Auth::user()->StudentID)->whereRaw('quiztaken.quizID = quizgrouppage.quizID')->where('delFlag', 0); })->get(); } return View::make('validated.more', compact('user', 'adminGroupPages', 'groupPages', 'files', 'fileFolders', 'activities', 'quizzes')); }
public static function isMember($id, $StudentID) { $check = GroupPageMember::where('grouppageID', $id)->where('StudentID', $StudentID)->where('delFlag', 0)->first(); return $check ? true : false; }
public function forceLeave() { $in = Input::all(); $isAdmin = GroupPage::isAdmin($in['id'], $in['AccID']); $isAssistant = GroupPage::isAssistant($in['id'], $in['AccID']); $isMember = GroupPage::isMember($in['id'], $in['AccID']); if (!$isAdmin && $isMember) { GroupPageMember::where('grouppageID', $in['id'])->where('StudentID', $in['AccID'])->update(array('delFlag' => 1)); $isAssistant ? GroupPage::where('grouppageID', $in['id'])->update(array('assistantID' => Auth::user()->StudentID)) : ''; } }