Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/5.2' into 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 18, 2016
2 parents 2b52235 + b015a5b commit 1a3aa9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,15 @@ protected function addUpdatedAtColumn(array $values)
return $values;
}

$column = $this->model->getUpdatedAtColumn();
if (count($this->getQuery()->joins) > 0) {
$column = $this->model->getQualifiedUpdatedAtColumn();
} else {
$column = $this->model->getUpdatedAtColumn();
}

return Arr::add($values, $column, $this->model->freshTimestampString());
return array_merge($values, [
$column => $this->model->freshTimestampString(),
]);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,16 @@ public function getUpdatedAtColumn()
return static::UPDATED_AT;
}

/**
* Get the fully qualified "updated at" column.
*
* @return string
*/
public function getQualifiedUpdatedAtColumn()
{
return $this->getTable().'.'.$this->getUpdatedAtColumn();
}

/**
* Get a fresh timestamp for the model.
*
Expand Down

0 comments on commit 1a3aa9a

Please sign in to comment.