bbone/application/modules/User/models/User_model.php
suseendhiran17 19db1249a4 suseendhiran
2023-01-13 10:43:35 +05:30

86 lines
2.3 KiB
PHP

<?php
class User_model extends MY_Model {
public function get_user($id , $business_id)
{
$this->db->select('*');
$this->db->from('users');
$this->db->where('business_id', $business_id);
$this->db->order_by('id','DESC');
$this->db->where('md5(id) !=', $id);
// $this->db->where('role', 'user');
// $this->db->where('is_active', 1);
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_admin()
{
$this->db->select('*');
$this->db->from('users');
$this->db->where('role !=', 'sadmin');
// $this->db->order_by('id','ASC');
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_user_by_md5_id($id,$business_id)
{
$this->db->select('*');
$this->db->from('users');
if ($business_id != NULL) {
$this->db->where('business_id', $business_id);
}
$this->db->where('md5(id)', $id);
$query = $this->db->get();
$query = $query->row();
return $query;
}
public function delete_user_by_md5_id($id,$business_id)
{
$this->db->where('md5(id)', $id);
if ($business_id != NULL) {
$this->db->where('business_id', $business_id);
}
$this->db->set('is_active',0);
$this->db->update('users');
return;
}
public function activate_inactive_users($id,$business_id)
{
$this->db->where('md5(id)', $id);
if ($business_id != NULL) {
$this->db->where('business_id', $business_id);
}
$this->db->set('is_active',1);
$this->db->update('users');
return;
}
public function business()
{
$this->db->select('*');
$this->db->from('business');
$query = $this->db->get();
$query = $query->result();
return $query;
}
public function get_business_by_md5_id($business_id)
{
$this->db->select('B.* , state.name as state_name ');
$this->db->from('business B');
$this->db->join('state', 'state.id = B.state', 'left');
$this->db->where('B.is_active', 1);
$this->db->where('md5(uid)', $business_id);
$query = $this->db->get();
$query = $query->row();
return $query;
}
}