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.
46 lines
1.5 KiB
46 lines
1.5 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class User_subscription_model extends CI_Model {
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Fetch latest subscription by user id
|
|
*/
|
|
public function get_subscription($user_id=null) {
|
|
$this->db->select('u.first_name, u.last_name, s.id, s.subscriptionId, s.authorisationId, s.transactionReference, s.amount, s.expirationDate, s.transactionDateTime, s.payment_mode, s.status');
|
|
$this->db->join('user_subscription s', 'u.user_id = s.user_id', 'left');
|
|
$this->db->where('u.user_id', $user_id);
|
|
$this->db->order_by('s.date_created','DESC');
|
|
return $this->db->get('user u')->row();
|
|
}
|
|
|
|
/**
|
|
* Update subscription by user id
|
|
*/
|
|
public function update_subscription($id, $data) {
|
|
foreach ($data as $key => $value) {
|
|
$this->db->set($key, $value);
|
|
}
|
|
$this->db->where('id', $id);
|
|
return $this->db->update('user_subscription');
|
|
}
|
|
|
|
public function update_user($id, $data) {
|
|
foreach ($data as $key => $value) {
|
|
$this->db->set($key, $value);
|
|
}
|
|
$this->db->where('user_id', $id);
|
|
return $this->db->update('user');
|
|
}
|
|
|
|
public function update_subscriber($id, $data) {
|
|
foreach ($data as $key => $value) {
|
|
$this->db->set($key, $value);
|
|
}
|
|
$this->db->where('subscriber_id', $id);
|
|
return $this->db->update('user_subscriber');
|
|
}
|
|
}
|
|
|