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
59 lines
1.5 KiB
PHP
59 lines
1.5 KiB
PHP
<?php
|
|
|
|
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,
|
|
]);
|
|
}
|
|
}
|