Explore/ismail #12
@@ -1127,6 +1127,39 @@ public function AdminsearchCustomerBySAG(Request $request)
|
|||||||
return response()->json(['message' => 'Customer PDPA updated successfully.'], 200);
|
return response()->json(['message' => 'Customer PDPA updated successfully.'], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store MyKad photo for an existing customer only when gambar_mykad is empty.
|
||||||
|
*/
|
||||||
|
public function storeMykadPhotoIfMissing($ic, Request $request)
|
||||||
|
{
|
||||||
|
$customer = Customer::on('mysql7')
|
||||||
|
->where('kplama', '=', $ic)
|
||||||
|
->orWhere('kpbaru', '=', $ic)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$customer) {
|
||||||
|
return response()->json(['error' => 'Customer not found.', 'stored' => false], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($customer->gambar_mykad)) {
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'MyKad photo already stored.',
|
||||||
|
'gambar_mykad' => $customer->gambar_mykad,
|
||||||
|
'stored' => false,
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->attachMykadPhoto($customer, $request);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => !empty($customer->gambar_mykad)
|
||||||
|
? 'MyKad photo stored.'
|
||||||
|
: 'No photo provided or store failed.',
|
||||||
|
'gambar_mykad' => $customer->gambar_mykad,
|
||||||
|
'stored' => !empty($customer->gambar_mykad),
|
||||||
|
], 200);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save MyKad photo into arrahn_files and link it on customer.gambar_mykad.
|
* Save MyKad photo into arrahn_files and link it on customer.gambar_mykad.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ $router->group(['prefix'=>'api'], function () use ($router){
|
|||||||
$router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']);
|
$router->get('customers/{ic}/gadai/{status}',['uses'=>'CustomerController@showOneCustomerGadai']);
|
||||||
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);
|
$router->get('customers/{ic}/gadai/{status}/{kodcaw}',['uses'=>'CustomerController@showOneCustomerGadaiByCawangan']);
|
||||||
$router->post('customers/create/{kodcaw}',['uses'=>'CustomerController@createCustomer']);
|
$router->post('customers/create/{kodcaw}',['uses'=>'CustomerController@createCustomer']);
|
||||||
|
$router->post('customers/{ic}/mykad-photo', ['uses' => 'CustomerController@storeMykadPhotoIfMissing']);
|
||||||
$router->delete('customers/{kodcaw}/{nokp}', ['uses' => 'CustomerController@delete']);
|
$router->delete('customers/{kodcaw}/{nokp}', ['uses' => 'CustomerController@delete']);
|
||||||
$router->put('customers/update/{nokp}', ['uses' => 'CustomerController@customerUpdate']);
|
$router->put('customers/update/{nokp}', ['uses' => 'CustomerController@customerUpdate']);
|
||||||
$router->put('customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CustomerController@customerUpdateKaunter']);
|
$router->put('customers/update/kaunter/{nokp}/{kodcaw}', ['uses' => 'CustomerController@customerUpdateKaunter']);
|
||||||
|
|||||||
Reference in New Issue
Block a user