/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . 'modifiyng' . PHP_EOL);
     $sessions = ClassroomSession::select('id', 'teacher_id', 'admin_link', 'subject_subject_id', 'interval_id', 'title', 'wiziq_id', 'duration', 'start_at')->whereDate('start_at', '=', date('Y-m-d'))->with('subject', 'interval', 'teacher')->get();
     foreach ($sessions as $session) {
         try {
             $classroom = WiziqClassroom::build($session->interval->title . " - " . $session->subject->name, new \DateTime($session->start_at))->withDuration($session->duration)->withPresenter($session->teacher->id, $session->teacher->name)->withAttendeeLimit(config("classrooms.attendee_limit"))->withReturnUrl('')->withCreateRecording(true)->withPresenterDefaultControls('audio, video')->withTimeZone("Asia/Muscat")->withStatusPingUrl("https://www.google.com")->withLanguageCultureName("ar-SA");
             $WiziqApi = new WiziqApi();
             $WiziqApi->modify($session->wiziq_id, $classroom);
             $attendees = Attendees::build()->add(9999999999.0, 'النظام', 'ar-SA');
             $response = $WiziqApi->addAttendeesToClass($session->wiziq_id, $attendees);
             $session->admin_link = $response[0]['url'];
             $session->save();
         } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) {
             Mail::send('emails.classrooms_modify', ['error' => $e->getMessage(), 'time' => $session->start_at], function ($m) {
                 $m->to('*****@*****.**', 'علي اليزيدي')->to('*****@*****.**', 'محسن بخيش')->subject('حدث مشكل اثناء تعديل الفصول');
             });
             $this->comment(PHP_EOL . $e->getMessage() . " - " . $session->id . ' - ' . $session->start_at . PHP_EOL);
         } catch (\mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
             Mail::send('emails.classrooms_modify', ['error' => $e->getMessage(), 'time' => $session->start_at], function ($m) {
                 $m->to('*****@*****.**', 'علي اليزيدي')->to('*****@*****.**', 'محسن بخيش')->subject('حدث مشكل اثناء تعديل الفصول');
             });
             $this->comment(PHP_EOL . $e->getMessage() . " - " . $session->id . ' - ' . $session->start_at . PHP_EOL);
         }
     }
     $this->comment(PHP_EOL . 'finished modifiyng' . PHP_EOL);
 }
 public function update(ClassroomSession $session, UpdateClassroomSessionRequest $request)
 {
     if ($session->start_at->isPast()) {
         return redirect()->route('classrooms.sessions.index')->with('error', trans('classrooms::sessions.cant_modify_started_sessions'));
     }
     $session->load('subject', 'interval', 'teacher');
     $session->fill($request->only('duration', 'start_at', 'title'));
     $session->save();
     try {
         $classroom = WiziqClassroom::build($session->interval->title . " - " . $session->subject->name, new \DateTime($session->start_at))->withDuration($session->duration)->withPresenter($session->teacher->id, $session->teacher->name)->withAttendeeLimit(config("classrooms.attendee_limit"))->withReturnUrl('')->withCreateRecording(true)->withPresenterDefaultControls('audio, video')->withTimeZone("Asia/Muscat")->withStatusPingUrl("https://google.com")->withLanguageCultureName("ar-SA");
         $WiziqApi = new WiziqApi();
         $response = $WiziqApi->modify($session->wiziq_id, $classroom);
     } catch (mikemix\Wiziq\Common\Api\Exception\CallException $e) {
         die($e->getMessage());
     } catch (mikemix\Wiziq\Common\Http\Exception\InvalidResponseException $e) {
         die($e->getMessage());
     }
     return redirect()->route('classrooms.sessions.index');
 }