public function isExistsAmongTwoUsers($user1, $user2) { $conversation = Conversation::where('user_one', $user1)->where('user_two', $user2); if ($conversation->exists()) { return $conversation->first()->id; } return false; }
/** * make sure is this conversation exist for this user with currently loggedin user. * * @param int $userId * @return bool|int */ public function isConversationExists($userId) { if (empty($userId)) { return false; } $user = $this->getSerializeUser($this->authUserId, $userId); return $this->conversation->isExistsAmongTwoUsers($user['one'], $user['two']); }