Skip to content
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
14 changes: 6 additions & 8 deletions src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -1461,14 +1461,14 @@ public function save(array $options = [])
// that is already in this database using the current IDs in this "where"
// clause to only update this model. Otherwise, we'll just insert them.
if ($this->exists) {
$saved = $this->performUpdate($query, $options);
$saved = $this->performUpdate($query);
}

// If the model is brand new, we'll insert it into our database and set the
// ID attribute on the model to the value of the newly inserted row's ID
// which is typically an auto-increment value managed by the database.
else {
$saved = $this->performInsert($query, $options);
$saved = $this->performInsert($query);
}

if ($saved) {
Expand Down Expand Up @@ -1514,10 +1514,9 @@ protected function finishSave(array $options)
* Perform a model update operation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $options
* @return bool
*/
protected function performUpdate(Builder $query, array $options = [])
protected function performUpdate(Builder $query)
{
$dirty = $this->getDirty();

Expand All @@ -1532,7 +1531,7 @@ protected function performUpdate(Builder $query, array $options = [])
// 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 && Arr::get($options, 'timestamps', true)) {
if ($this->timestamps) {
$this->updateTimestamps();
}

Expand All @@ -1555,10 +1554,9 @@ protected function performUpdate(Builder $query, array $options = [])
* Perform a model insert operation.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $options
* @return bool
*/
protected function performInsert(Builder $query, array $options = [])
protected function performInsert(Builder $query)
{
if ($this->fireModelEvent('creating') === false) {
return false;
Expand All @@ -1567,7 +1565,7 @@ protected function performInsert(Builder $query, array $options = [])
// 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 && Arr::get($options, 'timestamps', true)) {
if ($this->timestamps) {
$this->updateTimestamps();
}

Expand Down
16 changes: 0 additions & 16 deletions tests/Database/DatabaseEloquentModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1160,22 +1160,6 @@ public function testRelationshipTouchOwnersIsNotPropagatedIfNoRelationshipResult
$model->touchOwners();
}

public function testTimestampsAreNotUpdatedWithTimestampsFalseSaveOption()
{
$model = m::mock('EloquentModelStub[newQueryWithoutScopes]');
$query = m::mock('Illuminate\Database\Eloquent\Builder');
$query->shouldReceive('where')->once()->with('id', '=', 1);
$query->shouldReceive('update')->once()->with(['name' => 'taylor'])->andReturn(1);
$model->shouldReceive('newQueryWithoutScopes')->once()->andReturn($query);

$model->id = 1;
$model->syncOriginal();
$model->name = 'taylor';
$model->exists = true;
$this->assertTrue($model->save(['timestamps' => false]));
$this->assertNull($model->updated_at);
}

public function testModelAttributesAreCastedWhenPresentInCastsArray()
{
$model = new EloquentModelCastingStub;
Expand Down