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.5] Allow to create relations without attributes #19506

Merged
merged 1 commit into from
Jun 7, 2017
Merged

[5.5] Allow to create relations without attributes #19506

merged 1 commit into from
Jun 7, 2017

Conversation

antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented Jun 7, 2017

Copy of #19498
Pointed it to 5.5 to not change signature of the method in minor updates as Taylor said.

I found it useful in one of my packages where I need to create related record but all attributes are optional. Right now we need to bypass an empty array to the relation create method:

$user->bans()->create([]);

With this change we will be able to omit attributes variable:

$user->bans()->create();

By the way create method calls Illuminate\Database\Eloquent::newInstance which has default value for $attributes already:

public function newInstance($attributes = [], $exists = false)

@taylorotwell taylorotwell merged commit 975809a into laravel:master Jun 7, 2017
@antonkomarev antonkomarev deleted the feature/empty-relation-attributes-on-create branch June 7, 2017 14:15
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

2 participants