modified logic in upload ocr

This commit is contained in:
dhanabalan
2025-11-14 10:56:22 +05:30
parent adf1b57fd5
commit cd48b9bdf6

View File

@@ -35,25 +35,8 @@ class OcrValidationResource extends Resource
public $camera_capture; public $camera_capture;
public $serialNumbers = []; public $serialNumbers = [];
// protected $listeners = [
// 'set-serial-numbers' => 'fillSerialNumbers'
// ];
use InteractsWithForms; use InteractsWithForms;
// public function fillSerialNumbers($event)
// {
// $serialNumbers = $event['serialNumbers'] ?? [];
// $this->form->fill([
// 'serial_1' => $serialNumbers[0] ?? null,
// 'serial_2' => $serialNumbers[1] ?? null,
// 'serial_3' => $serialNumbers[2] ?? null,
// 'serial_4' => $serialNumbers[3] ?? null,
// ]);
// }
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form
@@ -125,7 +108,6 @@ class OcrValidationResource extends Resource
->directory('uploads/temp') ->directory('uploads/temp')
->preserveFilenames() ->preserveFilenames()
->reactive(), ->reactive(),
Forms\Components\Actions::make([ Forms\Components\Actions::make([
Action::make('uploadNow') Action::make('uploadNow')
->label('Upload PDF Now') ->label('Upload PDF Now')
@@ -142,7 +124,7 @@ class OcrValidationResource extends Resource
// $originalName = $uploaded->getClientOriginalName(); // $originalName = $uploaded->getClientOriginalName();
// $path = 'uploads/GRNumber/' . $originalName; // $path = 'uploads/GRNumber/' . $originalName;
$finalFileName = $safeName . '.pdf'; $finalFileName = $safeName . '.pdf';
$finalPath = 'uploads/OcrGRNumber/' . $finalFileName; $finalPath = 'uploads/OcrGrNumber/' . $finalFileName;
if (Storage::disk('local')->exists($finalPath)) { if (Storage::disk('local')->exists($finalPath)) {
Notification::make() Notification::make()
@@ -211,7 +193,7 @@ class OcrValidationResource extends Resource
} }
$storedPath = $uploaded->storeAs( $storedPath = $uploaded->storeAs(
'uploads/OcrGRNumber', 'uploads/OcrGrNumber',
$finalFileName, $finalFileName,
'local' 'local'
); );
@@ -285,7 +267,7 @@ class OcrValidationResource extends Resource
$grNumber = trim($grNumber); $grNumber = trim($grNumber);
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf'); //$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
$templatePath = storage_path("app/private/uploads/OcrGRNumber/{$grNumber}.pdf"); $templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
if(!file_exists($templatePath)) if(!file_exists($templatePath))
{ {
@@ -364,9 +346,14 @@ class OcrValidationResource extends Resource
$plant = Plant::find($plant); $plant = Plant::find($plant);
$grNumber = trim($grNumber);
//$templatePath = storage_path('app/private/uploads/StickerTemplateOcr/Single.pdf');
$templatePath = storage_path("app/private/uploads/OcrGrNumber/{$grNumber}.pdf");
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf'); // $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
$templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf"); //$templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf");
if(!file_exists($templatePath)) if(!file_exists($templatePath))
{ {
@@ -464,7 +451,7 @@ class OcrValidationResource extends Resource
return; return;
} }
$files = Storage::disk('local')->files('uploads/GRNumber'); $files = Storage::disk('local')->files('uploads/OcrGRNumber');
$fileToDownload = null; $fileToDownload = null;
foreach ($files as $file) { foreach ($files as $file) {
@@ -481,7 +468,6 @@ class OcrValidationResource extends Resource
->send(); ->send();
return; return;
} }
return response()->download(Storage::disk('local')->path($fileToDownload)); return response()->download(Storage::disk('local')->path($fileToDownload));
}), }),
]), ]),