Level 88
This should already work fro multiple models? You loop over each given model and apply the action. This is the correct implementation. Note that you need to select multiple models if you want to update multiple items.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Considering this code below which is an action applied to a Resource in Laravel Nova:
I can only update 1 row, however not multiple rows?
How do I fix the code to allow the ability to update multiple rows?
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
try {
$inventory = $model->inventory_item_id;
$quantity = $fields->quantity;
// Logging used for debugging
Log::info('UpdateAvailablity action called: $inventory: ' . $inventory . ', $quantity: ' . $quantity);
$inventoryLevelAvailabilityController = new InventoryLevelAvailabilityController();
$inventoryLevelAvailabilityController
->updateProductInventoryStockAvailable($inventory, $quantity);
} catch (\Exception $e) {
$this->markAsFailed($model, $e);
}
}
}
Please or to participate in this conversation.