Skip to content

Commit

Permalink
force integer on inc / dec
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 10, 2016
1 parent ebdc5d7 commit 915cb84
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,10 @@ public function update(array $values)
*/
public function increment($column, $amount = 1, array $extra = [])
{
if (! is_numeric($amount)) {
throw new InvalidArgumentException("Non-numeric value passed to increment method.");
}

$wrapped = $this->grammar->wrap($column);

$columns = array_merge([$column => $this->raw("$wrapped + $amount")], $extra);
Expand All @@ -1863,6 +1867,10 @@ public function increment($column, $amount = 1, array $extra = [])
*/
public function decrement($column, $amount = 1, array $extra = [])
{
if (! is_numeric($amount)) {
throw new InvalidArgumentException("Non-numeric value passed to decrement method.");
}

$wrapped = $this->grammar->wrap($column);

$columns = array_merge([$column => $this->raw("$wrapped - $amount")], $extra);
Expand Down

0 comments on commit 915cb84

Please sign in to comment.