Exemple #1
0
 /**
  * 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!');
 }
Exemple #2
0
 /**
  * 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, ['*****@*****.**']);
         }
     }
 }