// app/Filament/Resources/TaskResource/Pages/EditTask.php
...
protected $listeners = ['update-stock' => 'updateProductStock'];
public function updateProductStock($args)
{
$productId = $args['product_id'];
$stock = $args['stock'];
// $args are array holding 'productId' and 'stock' key
// here I want to update field that is inside of the repeater field
// repeater field is called 'taskItems' and every repeater item
// has fields 'product_id' and 'stock'. This is what I was trying to do:
$items = $this->data['taskItems'];
foreach($items as $item) {
if ($item['product_id'] == $productId) {
$item['stock'] = $stock;
break;
}
}
}
...
// app/Filament/Resources/TaskResource/Pages/EditTask.php
...
protected $listeners = ['update-stock' => 'updateProductStock'];
public function updateProductStock($args)
{
$productId = $args['product_id'];
$stock = $args['stock'];
// $args are array holding 'productId' and 'stock' key
// here I want to update field that is inside of the repeater field
// repeater field is called 'taskItems' and every repeater item
// has fields 'product_id' and 'stock'. This is what I was trying to do:
$items = $this->data['taskItems'];
foreach($items as $item) {
if ($item['product_id'] == $productId) {
$item['stock'] = $stock;
break;
}
}
}
...