From fb91bea7c477cf0118af6c988e7e4150a2744823 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 26 May 2026 15:27:25 +0530 Subject: [PATCH] changed logic in visito entry --- .../Pages/CreateVisitorEntry.php | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php b/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php index d654bad..5095d4f 100644 --- a/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php +++ b/app/Filament/Resources/VisitorEntryResource/Pages/CreateVisitorEntry.php @@ -111,29 +111,29 @@ class CreateVisitorEntry extends CreateRecord !empty($data['photo']) && str_starts_with($data['photo'], 'data:image') ) { - $imageData = explode(',', $data['photo'])[1]; + try { + $imageData = explode(',', $data['photo'])[1]; - $filename = 'visitor_' . time() . '_' . uniqid() . '.jpg'; + $filename = 'visitor_' . time() . '_' . uniqid() . '.jpg'; - $path = 'uploads/visitor-photos/' . $filename; + $path = 'visitor-photos/' . $filename; - Storage::disk('local')->put( - $path, - base64_decode($imageData) - ); + $decoded = base64_decode($imageData); - $decoded = base64_decode($imageData); + $saved = Storage::disk('public')->put($path, $decoded); - $saved = Storage::disk('local')->put($path, $decoded); + \Log::info('PHOTO UPLOAD (PUBLIC):', [ + 'filename' => $filename, + 'path' => $path, + 'size_bytes' => strlen($decoded), + 'saved' => $saved ? 'SUCCESS' : 'FAILED', + ]); - \Log::info('PHOTO UPLOAD: file details', [ - 'filename' => $filename, - 'path' => $path, - 'size_bytes' => strlen($decoded), - 'saved' => $saved ? 'SUCCESS' : 'FAILED', - ]); + $data['photo'] = $path; - $data['photo'] = $path; + } catch (\Exception $e) { + \Log::error('PHOTO UPLOAD ERROR: ' . $e->getMessage()); + } } return $data;