laravel/framework · error · InvalidArgumentException
Non-numeric value passed as decrement amount for column…
Error message
Non-numeric value passed as decrement amount for column: '$column'.
What it means
decrementEach() applies a numeric delta to each column in an associative map. For every entry it checks is_numeric($amount); a non-numeric value cannot be turned into 'col = col - amount' SQL, so it throws with the offending column name in the message.
Solutions
- Cast each amount when building the map: ['stock' => (int) $req->stock].
- Filter the input to keep only numeric entries before calling decrementEach().
- Validate the payload shape at the controller layer.
Example fix
// before ->decrementEach($request->adjustments) // ['stock' => 'two'] // after $dec = array_map(fn ($v) => (float) $v, $request->adjustments); ->decrementEach($dec)
Defensive patterns
Strategy: validation
Validate before calling
foreach ($columns as $col => $amt) {
if (! is_numeric($amt)) {
throw new InvalidArgumentException("{$col} must be numeric.");
}
}
$query->decrementEach($columns); Prevention
- Cast amounts when building the map: ['stock' => (int) $req->stock].
- Filter inputs to numeric values before decrementEach().
- Use form requests with 'numeric' rules for adjustment payloads.
When it happens
Trigger: ->decrementEach(['stock' => 'abc', 'reserved' => 1]), or any map where at least one value is non-numeric.
Common situations: Bulk-decrementing from a request payload without casting; mixing numeric and string metrics; refactoring single-column decrement() into a map and dropping a value.
Related errors
- Non-numeric value passed to decrement method.
- A subquery must be a query builder instance, a Closure, or…
- Nested arrays may not be passed to whereIn method.
- Non-associative array passed to decrementEach method.
- Non-numeric value passed as increment amount for column…
AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11).
Data as JSON: /api/errors/a537c8dbd3f43e54.
Report an issue: GitHub.
Appendix: 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 e0f6eb3518)