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

[5.3] Ignore return from closure in has one with default feature. #16636

Closed

Conversation

sileence
Copy link
Contributor

@sileence sileence commented Dec 3, 2016

In order to prevent a potential issues / inconsistencies with closures not returning a valid model, let's use the closure as a way to customize the default instance but ignoring the returned value.

In order words, passing a closure or an array to withDefault will be a way to customize the default instance not to replace it.

Fix: #16614

@sileence sileence changed the title Ignore return from closure in has one with default feature. [5.3] Ignore return from closure in has one with default feature. Dec 3, 2016
@taylorotwell
Copy link
Member

That is less flexible.

@patrickcarlohickman
Copy link
Contributor

@taylorotwell Unfortunately, it seems it is a little too flexible. Would you mind making a comment on #16614? Sorry for the wall of text, but the gist is that if a HasOne relationship returns something other than null or a Model instance, it can break code (e.g. the push() method).

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.

None yet

3 participants