Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[5.2] Replicate with default except values#13676

Merged
taylorotwell merged 1 commit into
laravel:5.2from
m1so:replicate-with-default-values
May 24, 2016
Merged

[5.2] Replicate with default except values#13676
taylorotwell merged 1 commit into
laravel:5.2from
m1so:replicate-with-default-values

Conversation

@m1so
Copy link
Copy Markdown
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