/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //Get all Scheduled responses for the next 24 horus that have been rescheduled by a note.
     $tosend = ResponseSchedule::whereNull('sent_date')->where('status', 'active')->whereBetween('scheduled_date', [Carbon::now(), Carbon::now()->addHours(24)])->has('note')->get();
     foreach ($tosend as $s) {
         $this->scheduler->notifyNoteTaker($s);
         $this->info($s->scheduled_date . " - " . Carbon::now());
     }
     $this->info($tosend->count('id'));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //Get Scheduled Responses and call teh SEND method for any found
     $tosend = ResponseSchedule::withoutGlobalScope(ResponseScheduleScope::class)->active()->where('scheduled_date', '<', Carbon::now())->get();
     foreach ($tosend as $s) {
         if ($s->response_template_detail_id == 0) {
             $this->scheduler->sendWebInquiryResponse($s);
         } else {
             $this->scheduler->send($s);
         }
         $this->info($s->scheduled_date . " - " . Carbon::now());
     }
     $this->info($tosend->count('id'));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $schedules = ResponseSchedule::with('detail')->where('status', 'paused')->where('updated_at', '<', Carbon::now()->subDays(3))->whereHas('contact.notes', function ($q) {
         $q->where('note_date', '>', Carbon::parse('3 days ago'));
     }, '<', 1)->get();
     $this->info($schedules);
     $schedules = $schedules->groupBy('detail.response_template_id');
     $i = 0;
     foreach ($schedules as $k => $s) {
         foreach ($s as $n) {
             if ($k != $i) {
                 $this->scheduler->notifyPauser($n);
                 $this->info($n);
                 $i = $k;
             }
         }
     }
 }
 public function getSchedulesbyTemplate(ResponseTemplate $template, Contact $contact)
 {
     $schedules = ResponseSchedule::whereHas('detail', function ($q) use($template) {
         $q->where('response_template_id', $template->id);
     })->where('user_id', $contact->id)->get();
     return $schedules;
 }
Ejemplo n.º 5
0
 public function scheduleInitialResponse(User $user)
 {
     //Schedule Initial Inquiry Response for 37 Minutes after Inquiry
     $schedule = ResponseSchedule::create(['user_id' => $user->id, 'response_template_detail_id' => 0, 'most_recent_note_id' => 0, 'scheduled_date' => Carbon::now()->addMinutes(23), 'status' => 'active']);
     return $schedule;
 }