/**
  * Execute the job.
  *
  * @return void
  */
 public function handle(Mailer $mailer)
 {
     $teachers = $this->teachers;
     foreach ($teachers as $teacher) {
         $message = new TeacherMessage();
         $message->sender_id = $this->sender_id;
         $message->email = $this->email;
         $message->sms = $this->sms;
         $message->teacher_id = $teacher->id;
         $data = ['content' => $this->email];
         $attachments = $this->attachments;
         if ($this->email) {
             $mailer->send('teachers::emails.message', $data, function ($m) use($teacher, $attachments) {
                 $m->to($teacher->email, $teacher->name)->from(config('teachers.from_email'))->subject("subject");
                 if (!empty($attachments)) {
                     foreach ($attachments as $a) {
                         $m->attach($a);
                     }
                 }
             });
             $message->email_sent = 1;
         }
         if ($this->sms) {
             $sms = new SmsGateway($this->sms, [$teacher->mobile]);
             $result = $sms->send();
             if ($result->getPushMessageResult()->PushMessageResult == 1) {
                 $message->sms_sent = 1;
             }
         }
         $message->save();
     }
     event(new TeachersMessagesQueueFinished());
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $sms = new SmsGateway($this->message, $this->receivers);
     $result = $sms->send();
     $sent = 0;
     //        \Log::info($result);
     if ($result && $result->getPushMessageResult()->PushMessageResult == 1) {
         $sent = 1;
     }
     event(new RegistrationStepChangedSmsSentEvent($this->message, $this->senderId, $this->registrationId, $sent));
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(Mailer $mailer)
 {
     $semester_id = semester()->id;
     $students = Student::whereIn('students.id', $this->students_ids)->select('students.id', 'students.registration_id', 'students.name', 'students.email', 'students.mobile', 'registrations.contact_email')->with('registration')->leftJoin('registrations', 'registrations.id', '=', 'students.registration_id')->groupBy('students.id')->get();
     $created_at = new DateTime();
     // $students = $this->students;
     $students_messages = [];
     foreach ($students as $student) {
         $student_message = [];
         $student_message['created_at'] = $created_at;
         $student_message['updated_at'] = $created_at;
         $student_message['sender_id'] = $this->sender_id;
         $student_message['semester_id'] = $semester_id;
         $student_message['email'] = $this->email;
         $student_message['sms'] = $this->sms;
         $student_message['student_id'] = $student->id;
         $student_message['email_sent'] = 0;
         $student_message['sms_sent'] = 0;
         if (!empty($this->email)) {
             try {
                 $mailer->send('students::emails.message', ['content' => $this->email], function ($m) use($student) {
                     if (!empty($student->registration) && !empty($student->registration->contact_email)) {
                         if (filter_var($student->registration->contact_email, FILTER_VALIDATE_EMAIL)) {
                             $m->cc([$student->registration->contact_email]);
                         }
                     }
                     $m->to($student->email, $student->name)->subject("مركز التعليم عن بعد");
                 });
                 $student_message['email_sent'] = 1;
             } catch (\Swift_RfcComplianceException $e) {
             }
         }
         $mobile_number = $student->mobile;
         if (substr($mobile_number, 0, 3) != 968 && substr($mobile_number, 0, 5) != '00968') {
             $mobile_number = '968' . $mobile_number;
         }
         if (substr($mobile_number, 0, 5) == '00968') {
             $mobile_number = str_replace('00968', '968', $mobile_number);
         }
         // \Log::info($mobile_number);
         if (!empty(trim($this->sms)) && strlen($mobile_number) == 11) {
             $sms = new SmsGateway($this->sms, [$mobile_number]);
             $result = $sms->send();
             if ($result == true or $result->getPushMessageResult()->PushMessageResult == 1) {
                 $student_message['sms_sent'] = 1;
             }
         }
         $students_messages[] = $student_message;
         // $message->save();
     }
     DB::table('student_messages')->insert($students_messages);
     event(new StudentsMessagesQueueFinished());
 }
Beispiel #4
0
 /**
  * reply the specified resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function reply(Request $request)
 {
     //temp for order
     $ticket = Ticket::findOrFail($request->ticket_id);
     $ticket->priority = 'high';
     $ticket->open = 1;
     $ticket->save();
     //end
     $reply = new TicketReply();
     $reply->fill($request->only('ticket_id', 'body'));
     $reply->owner_type = 'students';
     $reply->owner_id = $this->student->id;
     $reply->save();
     if ($this->student->id == 10001) {
         $sms = new SmsGateway('important ticket', ['96899487874']);
         $sms->send();
         $sms = new SmsGateway('important ticket', ['96895845885']);
         $sms->send();
     }
     return response()->json($reply, 200, [], JSON_NUMERIC_CHECK);
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $sms = new SmsGateway($this->message, $this->receivers);
     $sms->send();
 }