コード例 #1
0
 public function sendMessage($params)
 {
     $conversation = $params['cid'];
     $content = $params['message'];
     $user_id = Session::get('id');
     $conversation_details = MfrChat::find($conversation)[0];
     if ($conversation_details->user_1 == $user_id) {
         $other_user_id = $user_id;
     } else {
         $other_user_id = $conversation_details->user_2;
     }
     $m = new MfrChatMessages();
     $m->date_created = time();
     $m->user_id = $user_id;
     $m->content = $content;
     $m->save();
     $s = new ServerController();
     $s->notify($other_user_id, 'm');
     return $m;
 }