Custom Livewire component that sets a new item to the repeater component inside the resource's form
I have an OrderResource form. Inside that form I use the Repeater component to handle the orderlines entries for the Order Model. Each Orderline item inside the Repeater has a SELECT Input for product_id, quantity, overwrite prices inputs etc.
I have made another custom component called Scanner that uses a scanner library for qrcodes. I have made all the logic to find a product and now I am stuck on how to interacts with the form's state and specifically with the repeaters state to set a new entry
class Scanner extends Component
{
public bool $scannerOpen = false;
#[On('scanQRCode')]
public function addQRProduct($qrcode)
{
$product = Product::where('qrcode', $qrcode)->first();
if ($product) {
Notification::make()
->title('Βρέθηκε το ' . __('Product.label') . ' ' . $qrcode)
->success()
->send();
$newOrderline = [
// product_id
// quantity
// tax_amount
// ....
];
// Update repeaters state...
}
}
}
0 Replies