public function chkIsValidDiscussion($discussion_id) { $d_arr = Discussion::whereRaw('discussion_id = ? AND visibility_status = ?', array($discussion_id, 1))->first(); if (count($d_arr) > 0) { //Condition to show set as private based on logged in user(buyer/seller/admin) if ($this->logged_user_id == $d_arr['buyer_id']) { $this->set_as_private_note = trans('mp_product/viewProduct.private_question_set_as_private_buyer_note'); } elseif ($this->logged_user_id == $d_arr['seller_id']) { $this->set_as_private_note = trans('mp_product/viewProduct.private_question_set_as_private_seller_note'); } elseif (CUtil::isStaff()) { $this->set_as_private_note = trans('mp_product/viewProduct.private_question_set_as_private_admin_note'); } //condition to allow to set/unset question as private only by buyser, seller and staff if (CUtil::isStaff() || $this->logged_user_id == $d_arr['buyer_id'] || $this->logged_user_id == $d_arr['seller_id']) { return $d_arr; } } return false; }