From 13017082b6e18012d76f457bab29be893ff96374 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 1 Dec 2026 15:31:24 +0530 Subject: [PATCH 1/3] Added pdf shown logic in part validation error --- .../part-validation-error-icon.blade.php | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/resources/views/components/part-validation-error-icon.blade.php b/resources/views/components/part-validation-error-icon.blade.php index e858bc51..7ac08649 100644 --- a/resources/views/components/part-validation-error-icon.blade.php +++ b/resources/views/components/part-validation-error-icon.blade.php @@ -13,7 +13,7 @@ @endif --}} -@if ($getState()) +{{-- @if ($getState())
+@endif --}} + +@if ($getState()) + + @php + $url = $getState() . '?v=' . time(); + + $extension = strtolower( + pathinfo(parse_url($getState(), PHP_URL_PATH), PATHINFO_EXTENSION) + ); + @endphp + +
+ + @if ($extension === 'pdf') + + + + @else + + + + @endif + +
+ +@else + +
+ +
+ @endif -- 2.49.1 From c342d54c7b6972934a840b1bf1bdebb6df850cbc Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 1 Dec 2026 15:33:09 +0530 Subject: [PATCH 2/3] Added logic for pdf shown in mail --- .../RequestCharacteristicResource.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/RequestCharacteristicResource.php b/app/Filament/Resources/RequestCharacteristicResource.php index 9533443b..2c736ed7 100644 --- a/app/Filament/Resources/RequestCharacteristicResource.php +++ b/app/Filament/Resources/RequestCharacteristicResource.php @@ -185,7 +185,29 @@ class RequestCharacteristicResource extends Resource } // Build filename - $fileName = "{$workFlowId}.png"; + // $fileName = "{$workFlowId}.png"; + + // $imageUrl = route('workflow.image', [ + // 'filename' => $fileName, + // ]); + + // $set('validation1_image_url', $imageUrl); + + $files = glob(storage_path("app/private/uploads/LaserDocs/{$workFlowId}.*")); + + if (empty($files)) { + $set('validation1_image_url', null); + + Notification::make() + ->title('Validation File Not Found') + ->body("No validation image or PDF found for Workflow ID: {$workFlowId}") + ->warning() + ->send(); + + return; + } + + $fileName = basename($files[0]); $imageUrl = route('workflow.image', [ 'filename' => $fileName, -- 2.49.1 From 7ca4eec96585e076bb1e8d0047e6fe534ce2adf4 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 1 Dec 2026 15:34:11 +0530 Subject: [PATCH 3/3] Added pdf shown logic in request characteristics route --- routes/web.php | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/routes/web.php b/routes/web.php index f31f55d0..92a23bb5 100644 --- a/routes/web.php +++ b/routes/web.php @@ -141,14 +141,43 @@ Route::get('/part-validation-image/{filename}', function ($filename) { return response()->file($path); })->name('part.validation.image'); -Route::get('/workflow-image/{filename}', function ($filename) { - $path = storage_path("app/private/uploads/LaserDocs/{$filename}"); +// Route::get('/workflow-image/{filename}', function ($filename) { +// $path = storage_path("app/private/uploads/LaserDocs/{$filename}"); - if (! file_exists($path)) { - abort(404, 'Image not found'); +// if (! file_exists($path)) { +// abort(404, 'Image not found'); +// } + +// return response()->file($path); +// })->name('workflow.image'); + +Route::get('/workflow-image/{filename}', function ($filename) { + + $directory = storage_path('app/private/uploads/LaserDocs'); + + $files = glob($directory . '/' . basename($filename)); + + if (empty($files)) { + abort(404, 'File not found'); } - return response()->file($path); + $path = $files[0]; + + $extension = strtolower(pathinfo($path, PATHINFO_EXTENSION)); + + if ($extension === 'pdf') { + return response()->file($path, [ + 'Content-Type' => 'application/pdf', + 'Content-Disposition' => 'inline; filename="' . basename($path) . '"', + ]); + } + + if (in_array($extension, ['png', 'jpg', 'jpeg'])) { + return response()->file($path); + } + + abort(403, 'Unsupported file format'); + })->name('workflow.image'); // web.php -- 2.49.1