/** * Execute the console command. * * @return mixed */ public function handle() { $date = new \DateTime(); $date->modify('+1 days'); $formatted_date = $date->format('Y-m-d'); $classLessons = ClassLesson::whereDate('time', '=', $formatted_date)->get(); foreach ($classLessons as $classLesson) { $lesson = $classLesson->lesson; $class = $classLesson->studyClass; $surveys = $lesson->surveys; foreach ($surveys as $survey) { $classSurvey = new ClassSurvey(); $classSurvey->class_id = $class->id; $classSurvey->survey_id = $survey->id; $classSurvey->send_status = 1; $gen = $class->gen; foreach ($class->registers()->where("status", 1)->get() as $register) { $student = $register->user; $surveyUser = SurveyUser::where('gen_id', $gen->id)->where('survey_id', $survey->id)->where('user_id', $student->id)->first(); if ($surveyUser == null) { $surveyUser = new SurveyUser(); $surveyUser->survey_id = $survey->id; $surveyUser->user_id = $student->id; $surveyUser->gen_id = $gen->id; $surveyUser->save(); } } $classSurvey->save(); } } $this->info('The surveys were sent successfully!'); }
public function change_class(Request $request) { $classLessonTo = ClassLesson::find($request->class_lesson_id_to); $classLessonFrom = ClassLesson::find($request->class_lesson_id_from); $register = $this->user->registers()->where('class_id', $request->origin_class_id)->first(); $attendance = $classLessonFrom->attendances()->where('register_id', $register->id)->first(); $attendance->class_lesson_id = $classLessonTo->id; $attendance->save(); Session::flash('message', 'Bạn đã chuyển buổi <strong style="font-weight: bold">' . $classLessonFrom->lesson->order . ': ' . $classLessonFrom->lesson->name . '</strong> sang lớp <strong style="font-weight: bold">' . $classLessonTo->studyClass->name . '</strong> thành công'); return redirect('student/classes/' . $request->origin_class_id); }
/** * Execute the console command. * * @return mixed */ public function handle() { $date = new \DateTime(); $date->modify('+1 days'); $formatted_date = $date->format('Y-m-d'); $classLessons = ClassLesson::whereDate('time', '=', $formatted_date)->get(); foreach ($classLessons as $classLesson) { $class = $classLesson->studyClass; $registers = $class->registers()->where('status', '=', 1)->get(); $lesson = $classLesson->lesson; foreach ($registers as $register) { $user = $register->user; send_mail_lesson($user, $lesson, $class, $formatted_date, ['*****@*****.**']); } } }
public function attendance_list(Request $request, $id) { $classLesson = ClassLesson::find($id); $attendance_list = $classLesson->attendances; $currentGen = Gen::getCurrentGen(); $this->data['current_gen'] = $currentGen; $this->data['attendances'] = $attendance_list; $this->data['classLesson'] = $classLesson; $this->data['current_tab'] = 18; return view('manage.attendance_list', $this->data); }