Added trigger create event logic in leak test reading
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m41s
Laravel Larastan / larastan (pull_request) Failing after 5m22s

This commit is contained in:
dhanabalan
2026-10-24 12:58:08 +05:30
parent cf1d6a1c05
commit cd17021097

View File

@@ -4,9 +4,55 @@ namespace App\Filament\Resources\LeakTestReadingResource\Pages;
use App\Filament\Resources\LeakTestReadingResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Livewire\Attributes\On;
class CreateLeakTestReading extends CreateRecord
{
protected static string $resource = LeakTestReadingResource::class;
public function processQR($value){
$qrCode = $value;
$parts = explode('|', $qrCode);
$plantId = $this->form->getState()['plant_id'];
if (! preg_match('/^[^|]+(?:\|[^|]+)?$/', $value)) {
Notification::make()
->title('Invalid QR Format')
->body('Expected format: ItemCode|SerialNumber')
->danger()
->send();
return;
}
$itemCode = $parts[0] ?? null;
$serialNumber = $parts[1] ?? null;
$this->form->fill([
'plant_id' => $plantId,
'item_code' => $itemCode,
'serial_number' => $serialNumber,
'test_status' => 'PASS'
]);
}
#[On('submit-leak-test-form')]
public function submitLeakTestForm(): void
{
$this->create();
}
protected function getRedirectUrl(): string
{
//return $this->getResource()::getUrl('create'); // Stay on Create Page after savin
return $this->getResource()::getUrl('create', [
'plant_id' => $this->data['plant_id'] ?? null,
]);
}
}