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.2] Replicate with default except values #13676

Merged
merged 1 commit into from
May 24, 2016
Merged

[5.2] Replicate with default except values #13676

merged 1 commit into from
May 24, 2016

Conversation

m1so
Copy link
Contributor

@m1so m1so commented May 24, 2016

When using replicate with specified 'except' columns the primary key, created at and updated at timestamp have to be specified manually. This change proposes to use them by default.

For example

$duplicate = $example->replicate([
    'description',
    $example->getKeyName(),
    $example->getUpdatedAtColumn(),
    $example->getCreatedAtColumn(),
]);

would be simplified to

$duplicate = $example->replicate([
    'description',
]);

Another option could be adding a boolean $useDefault (= false by default to be backwards compatible) argument to the method to determine whether or not to add primary key, created at and updated at timestamp columns.

$duplicate = $example->replicate([
    'description',
], true);
// Would be the same as
$duplicate = $example->replicate([
    'description',
    $example->getKeyName(),
    $example->getUpdatedAtColumn(),
    $example->getCreatedAtColumn(),
]);

Include primary key, created_at and updated_at timestamp in the 'except' array of Model's replicate method by default.
@taylorotwell taylorotwell merged commit 6cc507e into laravel:5.2 May 24, 2016
@GrahamCampbell GrahamCampbell changed the title Replicate with default except values [5.2] Replicate with default except values May 24, 2016
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