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

  1. Cast the amount: ->decrement('stock', (float) $amount).
  2. Guard with is_numeric() before calling.
  3. 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

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


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)