Skip to content

[5.4] Use timestamps property getter in Eloquent Model #17612

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

Merged
merged 1 commit into from Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ public function getDates()
{
$defaults = [static::CREATED_AT, static::UPDATED_AT];

return $this->timestamps ? array_merge($this->dates, $defaults) : $this->dates;
return $this->usesTimestamps() ? array_merge($this->dates, $defaults) : $this->dates;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait HasTimestamps
*/
public function touch()
{
if (! $this->timestamps) {
if (! $this->usesTimestamps()) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ protected function performUpdate(Builder $query)
// First we need to create a fresh query instance and touch the creation and
// update timestamp on the model which are maintained by us for developer
// convenience. Then we will just continue saving the model instances.
if ($this->timestamps) {
if ($this->usesTimestamps()) {
$this->updateTimestamps();
}

Expand Down Expand Up @@ -626,7 +626,7 @@ protected function performInsert(Builder $query)
// First we'll need to create a fresh query instance and touch the creation and
// update timestamps on this model, which are maintained by us for developer
// convenience. After, we will just continue saving these model instances.
if ($this->timestamps) {
if ($this->usesTimestamps()) {
$this->updateTimestamps();
}

Expand Down