Skip to content

Add withDefault to MorphOne relations. - #19788

Merged
taylorotwell merged 1 commit into
laravel:5.4from
sileence:morph_one_with_default
Jun 27, 2017
Merged

taylorotwell merged 1 commit into
laravel:5.4from
sileence:morph_one_with_default

Conversation

@sileence

Copy link
Copy Markdown
Contributor

This PR adds the default option for morph one relations.

I also moved the logic to a trait to avoid code duplication. The only difference between morphOne, hasOne and belongsTo was the code to create the related instance, so I extracted that to an abstract method. So in order to implement the withDefault feature in a relation, you need to include the trait HasDefault and then implement the newRelatedInstanceFor method. I hope this makes sense.

@sileence

Copy link
Copy Markdown
Contributor Author

cc @browner12 @decadence

@decadence

Copy link
Copy Markdown
Contributor

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants