Initial baseline WACloud CI3 production
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class User_management_model extends CI_Model
|
||||
{
|
||||
|
||||
public function get_all_users()
|
||||
{
|
||||
$query = $this->db->get('users');
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function get_users_by_session_id($id)
|
||||
{
|
||||
$this->db->from('users');
|
||||
$this->db->where('master_id', $id);
|
||||
return $this->db->get()->result_array();
|
||||
// $query = $this->db->get('users');
|
||||
// return $query->result_array();
|
||||
}
|
||||
|
||||
public function get_user_by_id($id)
|
||||
{
|
||||
$this->db->from('users');
|
||||
$this->db->where('id', $id);
|
||||
return $this->db->get()->row();
|
||||
}
|
||||
|
||||
public function get_phone_number_id($id)
|
||||
{
|
||||
return $this->db->select('id, phone_number')
|
||||
->from('whatsapp_numbers')
|
||||
->where('user_id', $id)
|
||||
->get()
|
||||
->result();
|
||||
}
|
||||
|
||||
// Fungsi baru untuk insert user
|
||||
public function insert_user($data)
|
||||
{
|
||||
return $this->db->insert('users', $data);
|
||||
}
|
||||
|
||||
// 🔹 Insert user baru
|
||||
public function insert($data) {
|
||||
$this->db->insert('users', $data);
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
// 🔹 Update user
|
||||
public function update($id, $data) {
|
||||
$this->db->where('id', $id);
|
||||
$this->db->update('users', $data);
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
// 🔹 Delete User
|
||||
public function delete($id)
|
||||
{
|
||||
$this->db->delete('users', ['id' => $id]);
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user