ranjith-dev #1302
@@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user