laravel/framework · error · InvalidArgumentException

Non-numeric value passed as increment amount for column…

Error message

Non-numeric value passed as increment amount for column: '$column'.

What it means

incrementEach() 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 to make debugging easy.

Solutions

  1. Cast each amount when building the map: ['views' => (int) $req->views, ...].
  2. Filter the input to keep only numeric entries before calling incrementEach().
  3. Validate the payload shape at the controller layer.

Example fix

// before
->incrementEach($request->counters)  // ['views' => 'two']

// after
$inc = array_map(fn ($v) => (float) $v, $request->counters);
->incrementEach($inc)
Defensive patterns

Strategy: validation

Validate before calling

foreach ($columns as $col => $amt) {
    if (! is_numeric($amt)) {
        throw new InvalidArgumentException("{$col} must be numeric.");
    }
}
$query->incrementEach($columns);

Prevention

When it happens

Trigger: ->incrementEach(['views' => 'abc', 'clicks' => 1]), or any associative array where at least one value is non-numeric.

Common situations: Bulk-updating counters from a request payload without casting; mixing numeric and string metrics; refactoring single-column increment() calls into a map and dropping a value.

Related errors


AI-assisted analysis of laravel/framework@e0f6eb3518 (2026-08-11). Data as JSON: /api/errors/3baef3783287af5e. Report an issue: GitHub.

Appendix: source

Thrown at src/Illuminate/Database/Query/Builder.php:4450

        }

        return $this->incrementEach([$column => $amount], $extra);
    }

    /**
     * Increment 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 incrementEach(array $columns, array $extra = [])
    {
        foreach ($columns as $column => $amount) {
            if (! is_numeric($amount)) {
                throw new InvalidArgumentException("Non-numeric value passed as increment amount for column: '$column'.");
            } elseif (! is_string($column)) {
                throw new InvalidArgumentException('Non-associative array passed to incrementEach method.');
            }

            $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

View on GitHub (pinned to e0f6eb3518)