laravel/framework · error · InvalidArgumentException
Non-numeric value passed to decrement method.
Error message
Non-numeric value passed to decrement method.
What it means
decrement() mirrors increment(): it produces 'col = col - amount' SQL and therefore requires a numeric amount. A non-numeric value is rejected up front before delegating to decrementEach().
Solutions
- Cast the amount: ->decrement('stock', (float) $amount).
- Guard with is_numeric() before calling.
- Omit the amount to use the default of 1.
Example fix
// before
->decrement('stock', $request->qty) // 'qty' = 'one'
// after
->decrement('stock', (float) $request->qty) Defensive patterns
Strategy: validation
Validate before calling
if (! is_numeric($amount)) {
throw new InvalidArgumentException('decrement amount must be numeric.');
}
$query->decrement($column, (float) $amount); Prevention
- Cast request input to int/float before decrement().
- Omit the amount argument for the default -1.
- Add a form-request rule: 'qty' => 'sometimes|numeric'.
When it happens
Trigger: ->decrement('stock', 'abc'), ->decrement('stock', null), or passing unvalidated request input that resolves to a non-numeric string.
Common situations: Passing user input without casting; null from optional fields; string values that are not cleanly numeric.
Related errors
- Non-numeric value passed as decrement amount for column…
- 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/92318cf58349f7f5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Illuminate/Database/Query/Builder.php:4473
$columns[$column] = $this->raw("{$this->grammar->wrap($column)} + $amount");
}
return $this->update(array_merge($columns, $extra));
}
/**
* Decrement a column's value by a given amount.
*
* @param string $column
* @param float|int $amount
* @return int<0, max>
*
* @throws \InvalidArgumentException
*/
public function decrement($column, $amount = 1, array $extra = [])
{
if (! is_numeric($amount)) {
throw new InvalidArgumentException('Non-numeric value passed to decrement method.');
}
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)) {View on GitHub (pinned to e0f6eb3518)