66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class Users extends BaseController
|
|
{
|
|
|
|
use ResponseTrait;
|
|
|
|
var $request;
|
|
|
|
function __construct()
|
|
{
|
|
$this->request = \Config\Services::request();
|
|
}
|
|
|
|
public function userDash(){
|
|
$in = $this->request->getGet();
|
|
$data = [];
|
|
if ($in['uid'] !=''){
|
|
$query = $this->db->query("SELECT * FROM customers WHERE uid = '".$in['uid']."' ");
|
|
|
|
$row = $query->getRowArray();
|
|
$data = [
|
|
'call_return' => '100',
|
|
'customer' => $row,
|
|
'loans' => $this->userLoan($in['uid'])
|
|
];
|
|
return $this->respond($data, 200);
|
|
}
|
|
else{
|
|
return $this->respond(['error'=>'empty uid'], 400);
|
|
}
|
|
|
|
//return $this->respond([], 400);
|
|
}
|
|
|
|
private function userLoan($uid){
|
|
$query = $this->db->query("SELECT a.uid AS application_uid,a.loan_amount,
|
|
a.payment_month,a.status,a.added,
|
|
a.updated
|
|
FROM applications a
|
|
LEFT JOIN customers c ON c.uid = a.customer_uid WHERE a.customer_uid='".$uid."' ");
|
|
return $query->getResult('array');
|
|
}
|
|
public function userProfile(){
|
|
$in = $this->request->getGet();
|
|
$data = [];
|
|
if ($in['uid'] !=''){
|
|
$query = $this->db->query("SELECT * FROM customers WHERE uid = '".$in['uid']."' ");
|
|
$row = $query->getRowArray();
|
|
$data = [
|
|
'call_return' => '100',
|
|
'customer' => $row
|
|
];
|
|
return $this->respond($data, 200);
|
|
}else{
|
|
return $this->respond(['error'=>'empty uid'], 400);
|
|
}
|
|
|
|
// return $this->respond([], 400);
|
|
}
|
|
|
|
} |