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