public function alterField(Model $model, Field $oldField, Field $newField, $strict = false)
    {
        $oldType = $oldField->dbType($this->connection);
        $newType = $newField->dbType($this->connection);
        if ((is_null($oldType) && is_null($oldField->relation)) || (is_null($newType) && is_null($newField->relation))) {
            throw new ValueError(
                sprintf(
                    'Cannot alter field %s into %s - they do not properly define '.
                    'db_type (are you using a badly-written custom field?)',
                    $newField->getName(),
                    $oldField->getName()
                )
            );
        } elseif (is_null($oldType) && is_null($newType) &&
            (
                null !== $oldField->relation->through &&
                null !== $newField->relation->through &&
                $oldField->relation->through->getMeta()->autoCreated &&
                $newField->relation->through->getMeta()->autoCreated
            )
        ) {
            $this->alterManyToMany($model, $oldField, $newField, $strict);
        } elseif (is_null($oldType) && is_null($newType) &&
            (
                null !== $oldField->relation->through &&
                null !== $newField->relation->through &&
                !$oldField->relation->through->getMeta()->autoCreated &&
                !$newField->relation->through->getMeta()->autoCreated
            )
        ) {
            return;
        } elseif (is_null($oldType) && is_null($newType)) {
            throw new  ValueError(
                sprintf(
                    'Cannot alter field %s into %s - they are not compatible types '.
                    '(you cannot alter to or from M2M fields, or add or remove through= on M2M fields)',
                    $oldField->getName(),
                    $newField->getName()
                )
            );
        }
        $this->doFieldAlter($model, $oldField, $newField, $strict);
    }
public function alterField(Model $model, Field $oldField, Field $newField, $strict = false)
    {
        $oldType = $oldField->dbType($this->connection);
        $newType = $newField->dbType($this->connection);
        if ((is_null($oldType) && is_null($oldField->relation)) || (is_null($newType) && is_null($newField->relation))) {
            throw new ValueError(
                sprintf(
                    'Cannot alter field %s into %s - they do not properly define '.
                    'db_type (are you using a badly-written custom field?)',
                    $newField->getName(),
                    $oldField->getName()
                )
            );
        } elseif (is_null($oldType) && is_null($newType) &&
            (
                null !== $oldField->relation->through &&
                null !== $newField->relation->through &&
                $oldField->relation->through->getMeta()->autoCreated &&
                $newField->relation->through->getMeta()->autoCreated
            )
        ) {
            $this->alterManyToMany($model, $oldField, $newField, $strict);
        } elseif (is_null($oldType) && is_null($newType) &&
            (
                null !== $oldField->relation->through &&
                null !== $newField->relation->through &&
                !$oldField->relation->through->getMeta()->autoCreated &&
                !$newField->relation->through->getMeta()->autoCreated
            )
        ) {
            return;
        } elseif (is_null($oldType) && is_null($newType)) {
            throw new  ValueError(
                sprintf(
                    'Cannot alter field %s into %s - they are not compatible types '.
                    '(you cannot alter to or from M2M fields, or add or remove through= on M2M fields)',
                    $oldField->getName(),
                    $newField->getName()
                )
            );
        }
        $this->doFieldAlter($model, $oldField, $newField, $strict);
    }
public function alterField ( Model $ model , Field $ oldField , Field $ newField , $ strict = false ) { $ oldType = $ oldField -> dbType ( $ this -> connection ) ; $ newType = $ newField -> dbType ( $ this -> connection ) ; if ( ( is_null ( $ oldType ) && is_null ( $ oldField -> relation ) ) || ( is_null ( $ newType ) && is_null ( $ newField -> relation ) ) ) { throw new ValueError ( sprintf ( 'Cannot alter field %s into %s - they do not properly define ' . 'db_type (are you using a badly-written custom field?)' , $ newField -> getName ( ) , $ oldField -> getName ( ) ) ) ; } elseif ( is_null ( $ oldType ) && is_null ( $ newType ) && ( null !== $ oldField -> relation -> through && null !== $ newField -> relation -> through && $ oldField -> relation -> through -> getMeta ( ) -> autoCreated && $ newField -> relation -> through -> getMeta ( ) -> autoCreated ) ) { $ this -> alterManyToMany ( $ model , $ oldField , $ newField , $ strict ) ; } elseif ( is_null ( $ oldType ) && is_null ( $ newType ) && ( null !== $ oldField -> relation -> through && null !== $ newField -> relation -> through && ! $ oldField -> relation -> through -> getMeta ( ) -> autoCreated && ! $ newField -> relation -> through -> getMeta ( ) -> autoCreated ) ) { return ; } elseif ( is_null ( $ oldType ) && is_null ( $ newType ) ) { throw new ValueError ( sprintf ( 'Cannot alter field %s into %s - they are not compatible types ' . '(you cannot alter to or from M2M fields, or add or remove through= on M2M fields)' , $ oldField -> getName ( ) , $ newField -> getName ( ) ) ) ; } $ this -> doFieldAlter ( $ model , $ oldField , $ newField , $ strict ) ; }
Allows a field's type, uniqueness, nullability, default, column,  constraints etc. to be modified.

Requires a copy of the old field as well so we can only perform changes that are required.
If strict is true, raises errors if the old column does not match old_field precisely.

@param Model      $model
@param Field      $oldField
@param Field      $newField
@param bool|false $strict

@throws ValueError

@since  1.1.0

@author Eddilbert Macharia (http://eddmash.com) <edd.cowan@gmail.com>
Allows a field s type uniqueness nullability default column constraints etc . to be modified .