コード例 #1
0
 public function involved_users()
 {
     $result = [];
     $involved_users = involvedUsers::where('case_id', '=', $this->id)->get();
     foreach ($involved_users as $involved_user) {
         $user = User::where('id', '=', $involved_user->user_id)->get()[0];
         $result[] = $user->organisation . ' ' . $user->name;
     }
     return $result;
 }
コード例 #2
0
 /**
  * adds user to involved_users and returns complete dialogue
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function reloadBackend(Request $request)
 {
     $all = $request->all();
     //load all new cases since $timestamp
     //
     if (isset($all['request'])) {
         $request = $all['request'];
         $result = [];
         $date = date('Y-m-d H:i:s', $request['last_updated']);
         //add new cases to result
         $result['data']['cases'] = emergencyCase::where('updated_at', '>', $date)->get();
         $result['data']['vehicles'] = Vehicle::where('updated_at', '>', $date)->get();
         if (isset($request['cases'])) {
             //add new messages to result
             $result['data']['messages'] = [];
             foreach ($request['cases'] as $caseData) {
                 $user = involvedUsers::where('case_id', '=', $caseData['id'])->where('user_id', '=', Auth::id());
                 $user->update(array('last_message_seen' => $caseData['last_message_received']));
                 $result['data']['messages'][$caseData['id']] = $this->getMessagesFromDB($caseData['id'], $caseData['last_message_received']);
             }
         }
         return $result;
     } else {
         return 'null';
     }
 }