on('messages.user_id', '=', 'users.id'); }) ->select('users.name', 'messages.message')->orderBy('messages.created_at') ->get(); return view('writeMessage', compact('messages')); } //Send Message public function sendMessage(Request $request) { $user = Auth::user(); $input = $request->all(); $redis = LRedis::connection(); if (!isset($input['message']) || trim($input['message']) === '') { } else { Message::create([ 'user_id' => $user->id, 'message' => $input['message'], ]); $data = ['message' => $input['message'], 'user' => $user->name]; $redis->publish('message', json_encode($data)); } } }