diff --git a/app/Http/Controllers/CustomerController.php b/app/Http/Controllers/CustomerController.php index 59fbb2c..41b41fa 100644 --- a/app/Http/Controllers/CustomerController.php +++ b/app/Http/Controllers/CustomerController.php @@ -27,6 +27,15 @@ class CustomerController extends Controller return response()->json($customer_all); } + public function showAllCustomersByCawangan($kodcaw) + { + $cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first(); + + $customer = Customer::on($cawangan['mysql'])->get(); + + return response()->json($customer); + } + public function showOneCustomerByIC($ic){ $cawangan_all = Cawangan::on('mysql7')->get(); diff --git a/routes/web.php b/routes/web.php index c890e18..18528fd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -21,6 +21,7 @@ $router->get('/', function () use ($router) { $router->group(['prefix'=>'api'], function () use ($router){ //Customer API $router->get('customers',['uses'=>'CustomerController@showAllCustomers']); + $router->get('customers/cawangan/{kodcaw}',['uses'=>'CustomerController@showAllCustomersByCawangan']); $router->get('customers/{ic}',['uses'=>'CustomerController@showOneCustomerByIC']); $router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']); $router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);