From cd48b9bdf6dc1af04cef5ad400d8a04a9e443e5b Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Fri, 14 Nov 2025 10:56:22 +0530 Subject: [PATCH] modified logic in upload ocr --- .../Resources/OcrValidationResource.php | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/app/Filament/Resources/OcrValidationResource.php b/app/Filament/Resources/OcrValidationResource.php index 76f39ea..a85d3c7 100644 --- a/app/Filament/Resources/OcrValidationResource.php +++ b/app/Filament/Resources/OcrValidationResource.php @@ -35,25 +35,8 @@ class OcrValidationResource extends Resource public $camera_capture; public $serialNumbers = []; - - // protected $listeners = [ - // 'set-serial-numbers' => 'fillSerialNumbers' - // ]; - 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 { return $form @@ -125,7 +108,6 @@ class OcrValidationResource extends Resource ->directory('uploads/temp') ->preserveFilenames() ->reactive(), - Forms\Components\Actions::make([ Action::make('uploadNow') ->label('Upload PDF Now') @@ -142,7 +124,7 @@ class OcrValidationResource extends Resource // $originalName = $uploaded->getClientOriginalName(); // $path = 'uploads/GRNumber/' . $originalName; $finalFileName = $safeName . '.pdf'; - $finalPath = 'uploads/OcrGRNumber/' . $finalFileName; + $finalPath = 'uploads/OcrGrNumber/' . $finalFileName; if (Storage::disk('local')->exists($finalPath)) { Notification::make() @@ -211,7 +193,7 @@ class OcrValidationResource extends Resource } $storedPath = $uploaded->storeAs( - 'uploads/OcrGRNumber', + 'uploads/OcrGrNumber', $finalFileName, 'local' ); @@ -285,7 +267,7 @@ class OcrValidationResource extends Resource $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/OcrGrNumber/{$grNumber}.pdf"); if(!file_exists($templatePath)) { @@ -364,9 +346,14 @@ class OcrValidationResource extends Resource $plant = Plant::find($plant); - // $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf'); + $grNumber = trim($grNumber); - $templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.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/StickerTemplateOcr/multi.pdf'); + + //$templatePath = storage_path("app/private/uploads/OcrGrNumber/'$grNumber'.pdf"); if(!file_exists($templatePath)) { @@ -464,7 +451,7 @@ class OcrValidationResource extends Resource return; } - $files = Storage::disk('local')->files('uploads/GRNumber'); + $files = Storage::disk('local')->files('uploads/OcrGRNumber'); $fileToDownload = null; foreach ($files as $file) { @@ -481,7 +468,6 @@ class OcrValidationResource extends Resource ->send(); return; } - return response()->download(Storage::disk('local')->path($fileToDownload)); }), ]),