protected function setForeignKeysToNull(Model $model, Relation $relation, array $keys)
    {
        if ( ! count($keys)) return;

        $key           = $this->normalizeForeignKey(head($keys));
        $model->{$key} = null;

        if (    count($keys) > 1
            &&  (   $relation instanceof MorphTo
                ||  $relation instanceof MorphOne
                ||  $relation instanceof MorphMany
            )
        ) {
            $key           = $this->normalizeForeignKey(array_values($keys)[1]);
            $model->{$key} = null;
        }

        $model->save();
    }
protected function setForeignKeysToNull(Model $model, Relation $relation, array $keys)
    {
        if ( ! count($keys)) return;

        $key           = $this->normalizeForeignKey(head($keys));
        $model->{$key} = null;

        if (    count($keys) > 1
            &&  (   $relation instanceof MorphTo
                ||  $relation instanceof MorphOne
                ||  $relation instanceof MorphMany
            )
        ) {
            $key           = $this->normalizeForeignKey(array_values($keys)[1]);
            $model->{$key} = null;
        }

        $model->save();
    }
protected function setForeignKeysToNull ( Model $ model , Relation $ relation , array $ keys ) { if ( ! count ( $ keys ) ) return ; $ key = $ this -> normalizeForeignKey ( head ( $ keys ) ) ; $ model -> { $ key } = null ; if ( count ( $ keys ) > 1 && ( $ relation instanceof MorphTo || $ relation instanceof MorphOne || $ relation instanceof MorphMany ) ) { $ key = $ this -> normalizeForeignKey ( array_values ( $ keys ) [ 1 ] ) ; $ model -> { $ key } = null ; } $ model -> save ( ) ; }
Sets the foreign keys to null on a given model.

@param Model    $model
@param Relation $relation
@param string[] $keys
Sets the foreign keys to null on a given model .