Changed image path of visitor photos
Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-05-26 14:33:06 +05:30
parent e7fa446fc3
commit b567f3ee02

View File

@@ -85,21 +85,45 @@ class CreateVisitorEntry extends CreateRecord
\Log::info('WEBCAM: photo-captured event received, length: ' . strlen($photo));
}
// protected function mutateFormDataBeforeCreate(array $data): array
// {
// \Log::info('WEBCAM: mutateFormDataBeforeCreate called, photo value: ' . substr($data['photo'] ?? 'NULL', 0, 50));
// if (
// !empty($data['photo']) &&
// str_starts_with($data['photo'], 'data:image')
// ) {
// $imageData = explode(',', $data['photo'])[1];
// $filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
// $path = 'visitor-photos/' . $filename;
// Storage::disk('public')->put($path, base64_decode($imageData));
// $data['photo'] = $path;
// \Log::info('WEBCAM: photo saved to ' . $path);
// }
// return $data;
// }
protected function mutateFormDataBeforeCreate(array $data): array
{
\Log::info('WEBCAM: mutateFormDataBeforeCreate called, photo value: ' . substr($data['photo'] ?? 'NULL', 0, 50));
if (
!empty($data['photo']) &&
str_starts_with($data['photo'], 'data:image')
) {
$imageData = explode(',', $data['photo'])[1];
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
$path = 'visitor-photos/' . $filename;
Storage::disk('public')->put($path, base64_decode($imageData));
$data['photo'] = $path;
\Log::info('WEBCAM: photo saved to ' . $path);
$filename = 'visitor_' . time() . '_' . uniqid() . '.jpg';
$path = 'visitor-photos/' . $filename;
// Stores in storage/app/private/visitor-photos
Storage::put(
'private/' . $path,
base64_decode($imageData)
);
$data['photo'] = 'private/' . $path;
}
return $data;