Wire::trackChange PHP Method

trackChange() public method

The change will only be recorded if $this->trackChanges is a positive value.
public trackChange ( string $what, mixed $old = null, mixed $new = null )
$what string Name of property that changed
$old mixed Previous value before change
$new mixed New value
    public function trackChange($what, $old = null, $new = null)
    {
        if ($this->trackChanges & self::trackChangesOn) {
            // establish it as changed
            if (array_key_exists($what, $this->changes)) {
                // remember last value so we can avoid duplication in hooks or storage
                $lastValue = end($this->changes[$what]);
            } else {
                $lastValue = null;
                $this->changes[$what] = array();
            }
            if (is_null($old) || is_null($new) || $lastValue !== $new) {
                $this->changed($what, $old, $new);
                // triggers ___changed hook
            }
            if ($this->trackChanges & self::trackChangesValues) {
                // track changed values, but avoid successive duplication of same value
                if (is_object($old) && $old === $new) {
                    $old = clone $old;
                }
                // keep separate copy of objects for old value
                if ($lastValue !== $old || !count($this->changes[$what])) {
                    $this->changes[$what][] = $old;
                }
            } else {
                // don't track changed values, just names of fields
                $this->changes[$what][] = null;
            }
        }
        return $this;
    }