mirror of
https://github.com/dyzulk/dyzulk-apps.git
synced 2026-01-26 13:22:02 +07:00
pertama commit
This commit is contained in:
30
application/models/AuthModel.php
Normal file
30
application/models/AuthModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class AuthModel extends CI_Model
|
||||
{
|
||||
public function cekUsername($username) {
|
||||
return $this->db->get_where('user', ['username' => $username])->row_array();
|
||||
}
|
||||
|
||||
|
||||
public function getMaxId($table, $field, $prefix) {
|
||||
$this->db->select_max($field);
|
||||
$this->db->like($field, $prefix, 'after');
|
||||
return $this->db->get($table)->row_array()[$field];
|
||||
}
|
||||
|
||||
|
||||
public function updateStatusOnline($user_id) {
|
||||
$data = array('status_login' => 'online');
|
||||
$this->db->where('id', $user_id);
|
||||
$this->db->update('users_account', $data);
|
||||
}
|
||||
|
||||
|
||||
public function updateStatusOffline($user_id) {
|
||||
$data = array('status_login' => 'offline');
|
||||
$this->db->where('id', $user_id);
|
||||
$this->db->update('users_account', $data);
|
||||
}
|
||||
}
|
||||
24
application/models/Transaction_model.php
Normal file
24
application/models/Transaction_model.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
class Transaction_model extends CI_Model {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
// Fungsi untuk mengambil data transaksi dengan join ke tabel users_account
|
||||
public function getTransactions() {
|
||||
$this->db->select('user_transaction.*, users_account.nama, users_account.email, users_account.image');
|
||||
$this->db->from('user_transaction');
|
||||
$this->db->join('users_account', 'user_transaction.user_email = users_account.email', 'left');
|
||||
$this->db->order_by('user_transaction.time_transaction', 'DESC');
|
||||
return $this->db->get()->result_array();
|
||||
}
|
||||
|
||||
public function getTransactionById($id) {
|
||||
$this->db->select('user_transaction.*, users_account.nama, users_account.email, users_account.image');
|
||||
$this->db->from('user_transaction');
|
||||
$this->db->join('users_account', 'user_transaction.user_email = users_account.email', 'left');
|
||||
$this->db->where('user_transaction.id', $id);
|
||||
return $this->db->get()->row_array();
|
||||
}
|
||||
}
|
||||
29
application/models/UserModel.php
Normal file
29
application/models/UserModel.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class UserModel extends CI_Model
|
||||
{
|
||||
|
||||
public function getUsers(){
|
||||
$query = $this->db->get('users_account');
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
public function getTotalUsers() {
|
||||
$query = $this->db->query("SELECT COUNT(*) AS total_users FROM users_account");
|
||||
return $query->row()->total_users;
|
||||
}
|
||||
|
||||
public function getTotalAmount() {
|
||||
$query = $this->db->query("SELECT SUM(amount) AS total_amount FROM user_transaction");
|
||||
return $query->row()->total_amount;
|
||||
}
|
||||
|
||||
public function getTotalOnlineUsers() {
|
||||
$this->db->select('COUNT(*) as total_online_users');
|
||||
$this->db->where('status_login', 'online');
|
||||
$query = $this->db->get('users_account');
|
||||
return $query->row()->total_online_users;
|
||||
}
|
||||
|
||||
}
|
||||
11
application/models/index.html
Normal file
11
application/models/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user