Skip to content

Commit

Permalink
[5.2] Fix issue #11815 (#13519)
Browse files Browse the repository at this point in the history
* Fix issue [#11815](#11815)

* Fix failed StyleCI analysis.
  • Loading branch information
Sam Rapaport authored and taylorotwell committed May 18, 2016
1 parent 4b502dc commit b015a5b
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 b015a5b

Please sign in to comment.