Eloquence\Behaviours\Cacheable::updateCacheRecord PHP Method

updateCacheRecord() public method

Updates a table's record based on the query information provided in the $config variable.
public updateCacheRecord ( array $config, string $operation, integer | float | double $amount, string $foreignKey )
$config array
$operation string Whether to increase or decrease a value. Valid values: +/-
$amount integer | float | double
$foreignKey string
    public function updateCacheRecord(array $config, $operation, $amount, $foreignKey)
    {
        if (is_null($foreignKey)) {
            return;
        }
        $config = $this->processConfig($config);
        $sql = DB::table($config['table'])->where($config['key'], $foreignKey);
        /*
         * Increment for + operator
         */
        if ($operation == '+') {
            return $sql->increment($config['field'], $amount);
        }
        /*
         * Decrement for - operator
         */
        return $sql->decrement($config['field'], $amount);
    }