diff --git a/app/Filament/Resources/OcrValidationResource.php b/app/Filament/Resources/OcrValidationResource.php index 536a8f5..eaecb9a 100644 --- a/app/Filament/Resources/OcrValidationResource.php +++ b/app/Filament/Resources/OcrValidationResource.php @@ -111,9 +111,11 @@ class OcrValidationResource extends Resource ->label('Captured File') ->default(null) ->reactive(), - Forms\Components\Hidden::make('serialNumbers') - ->default('[]') // empty array as default - ->dehydrated(), + // Forms\Components\Hidden::make('serialNumbers') + // ->default('[]') // empty array as default + // ->dehydrated(), + Forms\Components\Hidden::make('serial_numbers') + ->default('[]'), Forms\Components\Actions::make([ // Action::make('uploadNow1') @@ -262,7 +264,7 @@ class OcrValidationResource extends Resource // ]; // $hasSerial = collect($serialNumbers)->some(fn($s) => !empty($s)); - $serialNumbersJson = $get('serialNumbers'); // input name matches hidden input + $serialNumbersJson = $get('serial_numbers'); $serialNumbers = json_decode($serialNumbersJson, true) ?? []; dd($serialNumbers); @@ -312,9 +314,9 @@ class OcrValidationResource extends Resource $slots = [ ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial - ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial + ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial - ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial + ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial ]; $qrSlots = [ diff --git a/app/Filament/Resources/OcrValidationResource/Pages/CreateOcrValidation.php b/app/Filament/Resources/OcrValidationResource/Pages/CreateOcrValidation.php index 0b9417c..9e19062 100644 --- a/app/Filament/Resources/OcrValidationResource/Pages/CreateOcrValidation.php +++ b/app/Filament/Resources/OcrValidationResource/Pages/CreateOcrValidation.php @@ -11,4 +11,14 @@ class CreateOcrValidation extends CreateRecord protected static string $resource = OcrValidationResource::class; public $photo1; + + protected function mutateFormDataBeforeCreate(array $data): array + { + if (!empty($data['serial_numbers'])) { + $data['serial_numbers'] = json_decode($data['serial_numbers'], true); + } + + return $data; + } + } diff --git a/resources/views/fields/camera-capture.blade.php b/resources/views/fields/camera-capture.blade.php index f7bec05..1cf5c6b 100644 --- a/resources/views/fields/camera-capture.blade.php +++ b/resources/views/fields/camera-capture.blade.php @@ -741,6 +741,8 @@ function cameraCapture() { {{-- --}} {{-- --}} + + @@ -877,7 +879,7 @@ function cameraCapture() { // Extract serial numbers (digits only) const matches = detectedText.match(/\d+/g) || []; this.serialNumbers = matches.slice(0, 4); // take first 4 serials - + this.$refs.hiddenInputSerials.value = JSON.stringify(this.serialNumbers); //this.$refs.serialInput.value = JSON.stringify(this.serialNumbers); alert("Serial numbers stored in hidden input:\n" + this.$refs.serialInput.value); }