Refactor readFiles method in SapFileController to streamline file filtering logic

This commit is contained in:
dhanabalan
2025-09-26 10:13:41 +05:30
parent 7406f4c97e
commit 062f143dbb

View File

@@ -58,10 +58,13 @@ class SapFileController extends Controller
}
// Filter only .txt files
$files = array_filter($allFiles, function($file) use ($path) {
return $file !== '.' && $file !== '..' && is_file($path . $file)
&& pathinfo($file, PATHINFO_EXTENSION) === 'txt';
});
// $files = array_filter($allFiles, function($file) use ($path) {
// return $file !== '.' && $file !== '..' && is_file($path . $file)
// && pathinfo($file, PATHINFO_EXTENSION) === 'txt';
// });
$files = array_filter(scandir($path), function($item) use ($path) {
return is_file($path . $item) && pathinfo($item, PATHINFO_EXTENSION) === 'txt';
});
if (empty($files)) {
return response()->json([