public function hasChanged($fields)
    {
        if ($this->_snapshot === false) {
            throw new PreconditionException(['getChangedFields failed: `:model` instance is snapshot disabled', 'model' => static::class]);
        }

        /** @noinspection ForeachSourceInspection */
        foreach ((array)$fields as $field) {
            if (!isset($this->_snapshot[$field]) || $this->{$field} !== $this->_snapshot[$field]) {
                return true;
            }
        }

        return false;
    }
public function hasChanged($fields)
    {
        if ($this->_snapshot === false) {
            throw new PreconditionException(['getChangedFields failed: `:model` instance is snapshot disabled', 'model' => static::class]);
        }

        /** @noinspection ForeachSourceInspection */
        foreach ((array)$fields as $field) {
            if (!isset($this->_snapshot[$field]) || $this->{$field} !== $this->_snapshot[$field]) {
                return true;
            }
        }

        return false;
    }
public function hasChanged ( $ fields ) { if ( $ this -> _snapshot === false ) { throw new PreconditionException ( [ 'getChangedFields failed: `:model` instance is snapshot disabled' , 'model' => static :: class ] ) ; } /** @noinspection ForeachSourceInspection */ foreach ( ( array ) $ fields as $ field ) { if ( ! isset ( $ this -> _snapshot [ $ field ] ) || $ this -> { $ field } !== $ this -> _snapshot [ $ field ] ) { return true ; } } return false ; }
Check if a specific attribute has changed
This only works if the model is keeping data snapshots

@param string|array $fields

@return bool
Check if a specific attribute has changed This only works if the model is keeping data snapshots