Rymercyble's avatar

code review

Hello, I would like to know if doing things like this is worth it. This check if conversation already exist and if no then I save it so i can show every conversation for each user without need of sending query to table with all messages and conversation ids they belongs to

if(Conversation::where('conversation_id', $new_chat_id)->first() != null){
            return redirect("/messages/{$new_chat_id}");
        } else {
            Conversation::insert([
                'conversation_id' => $new_chat_id,
                'user1' => $id,
                'user2' => $recipient
            ]);
            return redirect("/messages/{$new_chat_id}");
        }
0 likes
1 reply

Please or to participate in this conversation.