You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.9 KiB
60 lines
1.9 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class User_registration_model extends CI_Model {
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Fetch only subscriber roles
|
|
*/
|
|
public function get_subscriber_roles($name=null) {
|
|
$this->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);
|
|
}
|
|
|
|
}
|
|
|