master

laravel/framework

Last updated at: 29/12/2023 09:21

DeviatesCastableAttributes.php

TLDR

This file contains an interface called DeviatesCastableAttributes which defines two methods, increment and decrement, for manipulating attribute values.

Methods

increment

This method is used to increment the value of an attribute. It takes the following parameters:

  • $model: An instance of the Illuminate\Database\Eloquent\Model class representing the model.
  • $key: A string representing the key of the attribute.
  • $value: The value to increment the attribute by.
  • $attributes: An array of attribute values.

The method returns the modified attribute value.

decrement

This method is used to decrement the value of an attribute. It takes the following parameters:

  • $model: An instance of the Illuminate\Database\Eloquent\Model class representing the model.
  • $key: A string representing the key of the attribute.
  • $value: The value to decrement the attribute by.
  • $attributes: An array of attribute values.

The method returns the modified attribute value.

<?php

namespace Illuminate\Contracts\Database\Eloquent;

interface DeviatesCastableAttributes
{
    /**
     * Increment the attribute.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return mixed
     */
    public function increment($model, string $key, $value, array $attributes);

    /**
     * Decrement the attribute.
     *
     * @param  \Illuminate\Database\Eloquent\Model  $model
     * @param  string  $key
     * @param  mixed  $value
     * @param  array  $attributes
     * @return mixed
     */
    public function decrement($model, string $key, $value, array $attributes);
}