opentok = new OpenTok(config('app.opentokApiKey'),config('app.opentokApiSecret')); $this->otSession = $this->opentok->createSession(array('mediaMode' => MediaMode::ROUTED)); $this->otSessionId = $this->otSession->getSessionId(); $this->otToken = $this->opentok->generateToken($this->otSessionId); view()->share('opentok',$this->opentok); view()->share('otSession',$this->otSession); view()->share('otSessionId',$this->otSessionId); view()->share('otToken',$this->otToken); } public function messages(Request $request, Client $patient){ $defaultCompanyClient = $this->getDefaultCompanyClientFromSession($patient); $defaultCompany = $defaultCompanyClient ? $defaultCompanyClient->company : null; $regardingClient = $patient; $messages = InternalMessage::where('regarding_client_id', $patient->id); if($defaultCompany){ $messages = InternalMessage::where('regarding_company_id', $defaultCompany->id); } $messages = $messages->orderBy('created_at', 'ASC')->paginate(100); return view('app.patient.company-client.messages', compact('patient', 'regardingClient', 'messages', 'defaultCompanyClient', 'defaultCompany')); } public function clientMessagesAttachments(Request $request, Client $patient, InternalMessage $message) { if(!$message) return ''; $output = []; foreach ($message->attachments as $attachment) { $output[] = '' . ' ' . $attachment->systemFile->file_name . ''; } return implode("", $output); } }