src/Traits/WorksWithRelations.php
protected function updateOrCreateBelongsToOne(array $fillable, Model $model, Relation $relation)
    {
        $related = $relation->getRelated();

        if (array_except($fillable, ['id'])) {
            if (!$relation->first()) {
                $record = $relation->associate($related->create($fillable));
                $model->save();
            } else {
                $record = $relation->update($fillable);
            }

            return $record;
        }

        return null;
    }
protected function updateOrCreateBelongsToOne(array $fillable, Model $model, Relation $relation)
    {
        $related = $relation->getRelated();

        if (array_except($fillable, ['id'])) {
            if (!$relation->first()) {
                $record = $relation->associate($related->create($fillable));
                $model->save();
            } else {
                $record = $relation->update($fillable);
            }

            return $record;
        }

        return null;
    }
protected function updateOrCreateBelongsToOne ( array $ fillable , Model $ model , Relation $ relation ) { $ related = $ relation -> getRelated ( ) ; if ( array_except ( $ fillable , [ 'id' ] ) ) { if ( ! $ relation -> first ( ) ) { $ record = $ relation -> associate ( $ related -> create ( $ fillable ) ) ; $ model -> save ( ) ; } else { $ record = $ relation -> update ( $ fillable ) ; } return $ record ; } return null ; }
BelongsToOne relation updateOrCreate logic.

@param array    $fillable The relation fillable.
@param Model    $model    The eloquent model.
@param Relation $relation The eloquent relation.

@return Model
BelongsToOne relation updateOrCreate logic .