laravel/framework · error · InvalidArgumentException
Non-numeric value passed as decrement amount for column: '$c
Error message
Non-numeric value passed as decrement amount for column: '$column'.
What it means
Thrown by decrementEach when one of the per-column amounts fails is_numeric(). decrementEach iterates an associative column => amount map and validates each amount, naming the offending column. It is the multi-column analogue of the single decrement guard.
Source
Thrown at src/Illuminate/Database/Query/Builder.php:4492
}
return $this->decrementEach([$column => $amount], $extra);
}
/**
* Decrement the given column's values by the given amounts.
*
* @param array<string, float|int|numeric-string> $columns
* @param array<string, mixed> $extra
* @return int<0, max>
*
* @throws \InvalidArgumentException
*/
public function decrementEach(array $columns, array $extra = [])
{
foreach ($columns as $column => $amount) {
if (! is_numeric($amount)) {
throw new InvalidArgumentException("Non-numeric value passed as decrement amount for column: '$column'.");
} elseif (! is_string($column)) {
throw new InvalidArgumentException('Non-associative array passed to decrementEach method.');
}
$columns[$column] = $this->raw("{$this->grammar->wrap($column)} - $amount");
}
return $this->update(array_merge($columns, $extra));
}
/**
* Delete records from the database.
*
* @param mixed $id
* @return int
*/
public function delete($id = null)
{View on GitHub (pinned to bd6b5437e6)
Solutions
- Validate every amount: `$request->validate(['stock' => 'numeric', 'reserved' => 'numeric']);`.
- Cast each value before building the map.
- Use the named column in the error to pinpoint the bad key.
- Separate free-text fields from numeric adjustment maps.
Example fix
// before
$model->decrementEach(['stock' => $req->stock, 'reserved' => $req->reserved]);
// => Non-numeric value passed as decrement amount for column: 'reserved'.
// after
$amounts = collect(['stock','reserved'])
->mapWithKeys(fn ($c) => [$c => (float) $request->input($c, 0)])
->toArray();
$model->decrementEach($amounts); Defensive patterns
Strategy: validation
Validate before calling
foreach ($amounts as $col => $amt) {
if (! is_numeric($amt)) {
throw new \InvalidArgumentException("Amount for {$col} must be numeric.");
}
}
$model->decrementEach($amounts); Type guard
/** @param array<string, int|float|numeric-string> $a */
function allAmountsNumeric(array $a): bool
{
return array_all($a, fn($v) => is_numeric($v));
} Try / catch
// Validate the whole map before calling decrementEach; the error names the offending column.
Prevention
- Validate batch adjustment inputs with array.* numeric rules.
- Cast each value before building the map.
- Use the column name in the error to locate the bad key.
When it happens
Trigger: `decrementEach(['stock' => $req->stock, 'reserved' => $req->r])` where one value is non-numeric. Reusing the same input map for incrementEach and decrementEach without re-validating.
Common situations: Bulk inventory adjustment endpoints; order processing that decrements several stock counters from a form; converting individual decrement() calls into decrementEach() and inheriting unvalidated inputs.
Related errors
- Non-numeric value passed to decrement method.
- Non-numeric value passed to increment method.
- Non-numeric value passed as increment amount for column: '$c
- Non-associative array passed to decrementEach method.
- A subquery must be a query builder instance, a Closure, or a
AI-assisted analysis of laravel/framework@bd6b5437e6 (2026-08-06).
Data as JSON: /data/errors/a537c8dbd3f43e54.json.
Report an issue: GitHub.