db->select('r.role_id, r.name, sp.price, sp.id AS price_id'); $this->db->join('subscription_price sp', 'r.role_id = sp.user_type AND sp.status = 1', 'left'); $this->db->where('r.isBOUser', 0); if(isset($name)) { $this->db->where('r.name', $name); } $this->db->where('r.deletedAt IS NULL'); $this->db->where('sp.status', 1); return $this->db->get('user_role r')->result_array(); } public function get_membership_name($user_type, $roles) { $name = ""; for($i = 0; $i < count($roles); $i++) { if($roles[$i]['price_id'] == $user_type) { $name = $roles[$i]['name']; break; } } return $name; } public function saveUser(array $userData) { $this->db->insert('user', $userData); return $this->db->insert_id(); } public function saveSubscriber(array $subscriberData) { $this->db->insert('user_subscriber', $subscriberData); return $this->db->insert_id(); } public function saveSubscription(array $subscriptionData) { $this->db->insert('user_subscription', $subscriptionData); return $this->db->insert_id(); } public function updateSubscriptionStatus(string $status) { $data = array( 'status' => $status ); $this->db->where('expirationDate <', date()); $this->db->where('expirationDate IS NOT NULL'); $this->db->where('expirationDate !=', $status); return $this->db->update('user_subscription', $data); } }