Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Revision 399 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 150
Zeile 3408... Zeile 3408...
3408
    {
3408
    {
3409
        if (! is_numeric($amount)) {
3409
        if (! is_numeric($amount)) {
3410
            throw new InvalidArgumentException('Non-numeric value passed to increment method.');
3410
            throw new InvalidArgumentException('Non-numeric value passed to increment method.');
3411
        }
3411
        }
Zeile -... Zeile 3412...
-
 
3412
 
-
 
3413
        return $this->incrementEach([$column => $amount], $extra);
-
 
3414
    }
-
 
3415
 
-
 
3416
    /**
-
 
3417
     * Increment the given column's values by the given amounts.
-
 
3418
     *
-
 
3419
     * @param  array<string, float|int|numeric-string>  $columns
-
 
3420
     * @param  array<string, mixed>  $extra
-
 
3421
     * @return int
-
 
3422
     *
-
 
3423
     * @throws \InvalidArgumentException
-
 
3424
     */
-
 
3425
    public function incrementEach(array $columns, array $extra = [])
-
 
3426
    {
-
 
3427
        foreach ($columns as $column => $amount) {
-
 
3428
            if (! is_numeric($amount)) {
3412
 
3429
                throw new InvalidArgumentException("Non-numeric value passed as increment amount for column: '$column'.");
-
 
3430
            } elseif (! is_string($column)) {
-
 
3431
                throw new InvalidArgumentException('Non-associative array passed to incrementEach method.');
Zeile 3413... Zeile 3432...
3413
        $wrapped = $this->grammar->wrap($column);
3432
            }
-
 
3433
 
Zeile 3414... Zeile 3434...
3414
 
3434
            $columns[$column] = $this->raw("{$this->grammar->wrap($column)} + $amount");
3415
        $columns = array_merge([$column => $this->raw("$wrapped + $amount")], $extra);
3435
        }
Zeile 3416... Zeile 3436...
3416
 
3436
 
3417
        return $this->update($columns);
3437
        return $this->update(array_merge($columns, $extra));
3418
    }
3438
    }
Zeile 3431... Zeile 3451...
3431
    {
3451
    {
3432
        if (! is_numeric($amount)) {
3452
        if (! is_numeric($amount)) {
3433
            throw new InvalidArgumentException('Non-numeric value passed to decrement method.');
3453
            throw new InvalidArgumentException('Non-numeric value passed to decrement method.');
3434
        }
3454
        }
Zeile -... Zeile 3455...
-
 
3455
 
-
 
3456
        return $this->decrementEach([$column => $amount], $extra);
-
 
3457
    }
-
 
3458
 
-
 
3459
    /**
-
 
3460
     * Decrement the given column's values by the given amounts.
-
 
3461
     *
-
 
3462
     * @param  array<string, float|int|numeric-string>  $columns
-
 
3463
     * @param  array<string, mixed>  $extra
-
 
3464
     * @return int
-
 
3465
     *
-
 
3466
     * @throws \InvalidArgumentException
-
 
3467
     */
-
 
3468
    public function decrementEach(array $columns, array $extra = [])
-
 
3469
    {
-
 
3470
        foreach ($columns as $column => $amount) {
-
 
3471
            if (! is_numeric($amount)) {
3435
 
3472
                throw new InvalidArgumentException("Non-numeric value passed as decrement amount for column: '$column'.");
-
 
3473
            } elseif (! is_string($column)) {
-
 
3474
                throw new InvalidArgumentException('Non-associative array passed to decrementEach method.');
Zeile 3436... Zeile 3475...
3436
        $wrapped = $this->grammar->wrap($column);
3475
            }
-
 
3476
 
Zeile 3437... Zeile 3477...
3437
 
3477
            $columns[$column] = $this->raw("{$this->grammar->wrap($column)} - $amount");
3438
        $columns = array_merge([$column => $this->raw("$wrapped - $amount")], $extra);
3478
        }
Zeile 3439... Zeile 3479...
3439
 
3479
 
3440
        return $this->update($columns);
3480
        return $this->update(array_merge($columns, $extra));
3441
    }
3481
    }