Пример #1
0
 public function showWelcome()
 {
     $message = '';
     //getting a flash message when a new chat room is created
     if (Session::has('message')) {
         $message = Session::get('message', 'default');
         Session::forget('message');
     }
     if (Auth::user()) {
         $chat_rooms = $this->getJoinedChatRooms();
         $unread_messages_counts = $this->getUnreadMessagesCount($chat_rooms);
         $online_members_per_room = $this->getOnlineMembers($chat_rooms);
         $available_chat_rooms = $this->getAvailableChatRooms();
         $invited_chatrooms = $this->getInvitedChatRoomDetails();
         $registered = Online::registered()->distinct('user_id')->get();
         $online_users = '';
         foreach ($registered as $register) {
             $online_users[] = $register->user_id;
         }
         //$online_users = array_unique($online_users);			var_dump($online_users);die();
         $user_names = User::select('first_name')->whereIn('id', array_unique($online_users))->lists('first_name');
         return View::make('home', array('chatrooms' => $chat_rooms, 'online_members' => $online_members_per_room, 'user_names' => $user_names, 'message' => $message, 'available_chat_rooms' => $available_chat_rooms, 'unread_messages_counts' => $unread_messages_counts, 'invited_chatrooms' => $invited_chatrooms));
     } else {
         Online::updateCurrent();
     }
     return View::make('home');
 }