DONE: auto add ic photo for existing customer
This commit is contained in:
@@ -289,6 +289,29 @@ class CustomersController extends Controller
|
||||
return response(["no-data"], 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store MyKad photo for an existing customer when gambar_mykad is still empty.
|
||||
*/
|
||||
public function storeMykadPhotoIfMissing(Request $request)
|
||||
{
|
||||
$icno = preg_replace('/[^0-9A-Za-z]/', '', (string) $request->input('icno'));
|
||||
if ($icno === '') {
|
||||
return response()->json(['error' => 'IC number is required.', 'stored' => false], 422);
|
||||
}
|
||||
|
||||
if (!$request->filled('photo_base64')) {
|
||||
return response()->json(['error' => 'Photo is required.', 'stored' => false], 422);
|
||||
}
|
||||
|
||||
$response = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post(config('api.url') . '/api/customers/' . $icno . '/mykad-photo', [
|
||||
'photo_base64' => $request->input('photo_base64'),
|
||||
'photo_mime' => $request->input('photo_mime') ?: 'image/jpeg',
|
||||
]);
|
||||
|
||||
return response()->json($response->json() ?? ['stored' => false], $response->status());
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user