Added file deletion logic if pdf is not valid
This commit is contained in:
@@ -124,6 +124,12 @@ class GrMasterResource extends Resource
|
||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
$item1 = $matches[1];
|
||||
}
|
||||
// else if (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
|
||||
|
||||
// $item2 = $matches[1];
|
||||
// dd($item2);
|
||||
// }
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
@@ -131,6 +137,10 @@ class GrMasterResource extends Resource
|
||||
->body('Could not find Item code in uploaded PDF.')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,6 +166,9 @@ class GrMasterResource extends Resource
|
||||
->body("Item not found in uploaded pdf.")
|
||||
->warning()
|
||||
->send();
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,15 +190,15 @@ class GrMasterResource extends Resource
|
||||
else
|
||||
{
|
||||
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Item Code not matched')
|
||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user