public function postStudentsAttendence() { // Request $request // return $GetStudents; $dateTime = Input::get('date'); $clasId = Input::get('class'); $sectionName = Input::get('section'); $today = date("Y-m-d"); $data1 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Student')->where('created_at', 'LIKE', "%{$today}%")->get(); if ($data1->count() == 0) { # code... $GetStudents = students::where('institute_code', '=', Auth::user()->institute_id)->where('class', '=', $clasId)->where('section', '=', $sectionName)->get(); foreach ($GetStudents as $key => $value) { //return $data1->count(); $stdAtn = new Attendence(); $stdAtn->institute_code = Auth::user()->institute_id; $stdAtn->uid = $value->st_id; $stdAtn->type = "Student"; $stdAtn->status = 0; $stdAtn->save(); //return redirect()->back(); } return view('admin.attendence.studentsAttendence')->with('allclass', $this->getallclass())->with('GetStudents', $GetStudents)->with('sectionName', $sectionName)->with('classId', $clasId)->with('dateTime', $dateTime); } else { # code... $GetStudents = DB::table('tbl_studets')->join('tbl_attendence', 'tbl_studets.st_id', '=', 'tbl_attendence.uid')->select('tbl_studets.*', 'tbl_attendence.*')->where('tbl_attendence.institute_code', '=', Auth::user()->institute_id)->where('tbl_studets.institute_code', '=', Auth::user()->institute_id)->where('tbl_attendence.type', '=', 'Student')->where('tbl_attendence.created_at', 'LIKE', "%{$today}%")->get(); return view('admin.attendence.studentsAttendence')->with('allclass', $this->getallclass())->with('GetStudents', $GetStudents)->with('sectionName', $sectionName)->with('classId', $clasId)->with('dateTime', $dateTime); } //return $GetStudents; }