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;
 }
 public static function getNewChatMessages($conversation_id)
 {
     $last_message = Session::get('last-chat-message');
     $messages = MfrChatMessages::where('conversation_id', $conversation_id)->also('id', '>', $last_message)->desc()->as_array()->get();
     $last_message = $messages[0]['id'];
     $messages = array_reverse($messages);
     $i = 0;
     foreach ($messages as $message) {
         $u = MfrUsers::find($message['user_id'])[0];
         if ($u->avatar == '' || ($u->avatar = null)) {
             $u->avatar = DEFAULT_IMAGE;
         }
         $messages[$i]['user-info'] = $u;
         $i++;
     }
     Session::set('last-chat-message', $last_message);
     return $messages;
 }