Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add withDefault to MorphOne relations. #19788

Merged
merged 1 commit into from
Jun 27, 2017

Conversation

sileence
Copy link
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
Contributor Author

cc @browner12 @decadence

@decadence
Copy link
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