Added logic fo serils
This commit is contained in:
@@ -54,9 +54,12 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
|||||||
|
|
||||||
//return response()->json(['success' => true, 'text' => $text]);
|
//return response()->json(['success' => true, 'text' => $text]);
|
||||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Z0-9]+$/i', $line));
|
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Za-z0-9]+$/', $line));
|
||||||
|
|
||||||
return response()->json(['success' => true, 'text' => array_values($serials)]);
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'text' => array_values($serials) // reindex array
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
//catch (\Exception $e) {
|
//catch (\Exception $e) {
|
||||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||||
|
|||||||
Reference in New Issue
Block a user