Explore/ismail #12

Merged
afrina merged 10 commits from explore/ismail into main 2026-09-09 14:47:34 +08:00
2 changed files with 34 additions and 0 deletions
Showing only changes of commit 03228cae2f - Show all commits
@@ -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.
*/ */
+1
View File
@@ -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']);