public function show($id)
    {
        try {
            $thread = Thread::findOrFail($id);
        } catch (ModelNotFoundException $e) {
            Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');

            return redirect('message');
        }

        // show current user in list if not a current participant
        // $users = User::whereNotIn('id', $thread->participantsUserIds())->get();

        // don't show the current user in list
        $userId = Auth::user()->id;
        $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();

        $thread->markAsRead($userId);

        return view('chat.show', compact('thread', 'users'));
    }
public function show($id)
    {
        try {
            $thread = Thread::findOrFail($id);
        } catch (ModelNotFoundException $e) {
            Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');

            return redirect('message');
        }

        // show current user in list if not a current participant
        // $users = User::whereNotIn('id', $thread->participantsUserIds())->get();

        // don't show the current user in list
        $userId = Auth::user()->id;
        $users = User::whereNotIn('id', $thread->participantsUserIds($userId))->get();

        $thread->markAsRead($userId);

        return view('chat.show', compact('thread', 'users'));
    }
public function show ( $ id ) { try { $ thread = Thread :: findOrFail ( $ id ) ; } catch ( ModelNotFoundException $ e ) { Session :: flash ( 'error_message' , 'The thread with ID: ' . $ id . ' was not found.' ) ; return redirect ( 'message' ) ; } // show current user in list if not a current participant // $users = User::whereNotIn('id', $thread->participantsUserIds())->get(); // don't show the current user in list $ userId = Auth :: user ( ) -> id ; $ users = User :: whereNotIn ( 'id' , $ thread -> participantsUserIds ( $ userId ) ) -> get ( ) ; $ thread -> markAsRead ( $ userId ) ; return view ( 'chat.show' , compact ( 'thread' , 'users' ) ) ; }
Shows a message thread

@param $id
@return mixed
Shows a message thread