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

Closed
wants to merge 1 commit into from
Closed

[5.4] Allow to create relations without attributes #19498

wants to merge 1 commit into from

Conversation

antonkomarev
Copy link
Contributor

@antonkomarev antonkomarev commented Jun 6, 2017

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)

@tillkruss tillkruss changed the title Allow to create relations without attributes [5.4] Allow to create relations without attributes Jun 7, 2017
@taylorotwell
Copy link
Member

I can't change the signature on minor release because anything extending that method would break.

@antonkomarev
Copy link
Contributor Author

Okay, I will point it to the 5.5 then

@antonkomarev antonkomarev deleted the feature/create-relation-without-attributes branch June 7, 2017 08:32
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.

2 participants