From 2e9275e82099cac8424940cfb99b89452184d30f Mon Sep 17 00:00:00 2001 From: Afiq Date: Thu, 31 Dec 2020 17:20:46 +0800 Subject: [PATCH] customer --- app/Http/Controllers/CustomerController.php | 30 +++++++++++++++++++-- routes/web.php | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 0c58353..b842a02 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -30,7 +30,7 @@ class CustomerController extends Controller public function getLatestCustomer($kodcaw){ $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); - $customer = Customer::on($cawangan['mysql'])->orderBy('tarikh','desc')->orderBy('nosiri','desc')->first(); + $customer = Customer::on($cawangan['mysql'])->orderBy('tarikhdaftar','desc')->orderBy('nosiri','desc')->first(); return response()->json($customer); } @@ -61,6 +61,30 @@ class CustomerController extends Controller return response()->json($customer_all); } + public function showOneCustomerByICMobile($ic){ + + $cawangan_all = Cawangan::on('mysql7')->get(); + $customer_all = []; + foreach($cawangan_all as $index=>$cawangan){ + $customer = Customer::on($cawangan['mysql']) + ->where('kplama','=',$ic) + ->orWhere('kpbaru','=',$ic) + ->first(); + if($customer != null){ + array_push($customer_all,$customer); + } + } + $customer_detail['nama'] = $customer_all[0]['nama']; + $customer_detail['nokp'] = $customer_all[0]['kpbaru']; + $customer_detail['nopelanggan'] = $customer_all[0]['nopelanggan']; + $customer_detail['telefon'] = $customer_all[0]['telefon']; + $customer_detail['telefon2'] = $customer_all[0]['telefon2']; + $customer_detail['alamat'] = $customer_all[0]['alamat1']; + $customer_detail['poskod'] = $customer_all[0]['poskod']; + + return response()->json($customer_detail); + } + public function showOneCustomerGadai($ic,$status){ if($status == 'belum_tebus'){ $gadai_status = ''; @@ -120,6 +144,7 @@ class CustomerController extends Controller } public function create($kodcaw,Request $request){ + dd($request); $current = Carbon::now(); $current = new Carbon(); @@ -146,7 +171,8 @@ class CustomerController extends Controller 'noakaun' => $request->noakaun, 'teller' => $request->teller, 'aktif' => 'A', - 'telefon2' => $request->telefon2 + 'telefon2' => $request->telefon2, + 'nosiri'=>$request->nosiri ]); return response()->json($customer, 201); diff --git a/routes/web.php b/routes/web.php index 1b38f66..832c766 100644 --- a/routes/web.php +++ b/routes/web.php @@ -23,6 +23,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('customers',['uses'=>'CustomerController@showAllCustomers']); $router->get('customers/cawangan/{kodcaw}',['uses'=>'CustomerController@showAllCustomersByCawangan']); $router->get('customers/{ic}',['uses'=>'CustomerController@showOneCustomerByIC']); + $router->get('customers/mobile/{ic}',['uses'=>'CustomerController@showOneCustomerByICMobile']); $router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']); $router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']); $router->post('customers/{kodcaw}',['uses'=>'CustomerController@create']);