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
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user