Skip to content

Commit

Permalink
Revert model syncing after soft-delete (#25392)
Browse files Browse the repository at this point in the history
  • Loading branch information
edbentinck authored and taylorotwell committed Aug 31, 2018
1 parent 45daf1e commit 90a844d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Illuminate/Database/Eloquent/SoftDeletes.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ protected function runSoftDelete()
$columns[$this->getUpdatedAtColumn()] = $this->fromDateTime($time);
}

if ($query->update($columns)) {
$this->syncOriginal();
}
$query->update($columns);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ public function testUpdateModelAfterSoftDeleting()
/** @var SoftDeletesTestUser $userModel */
$userModel = SoftDeletesTestUser::find(2);
$userModel->delete();
$userModel->syncOriginal();
$this->assertEquals($now->toDateTimeString(), $userModel->getOriginal('deleted_at'));
$this->assertNull(SoftDeletesTestUser::find(2));
$this->assertEquals($userModel, SoftDeletesTestUser::withTrashed()->find(2));
Expand All @@ -283,6 +284,7 @@ public function testRestoreAfterSoftDelete()
/** @var SoftDeletesTestUser $userModel */
$userModel = SoftDeletesTestUser::find(2);
$userModel->delete();
$userModel->syncOriginal();
$userModel->restore();

$this->assertEquals($userModel->id, SoftDeletesTestUser::find(2)->id);
Expand All @@ -301,6 +303,7 @@ public function testSoftDeleteAfterRestoring()
$this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::find(1)->deleted_at);
$this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::find(1)->deleted_at);
$userModel->delete();
$userModel->syncOriginal();
$this->assertNull(SoftDeletesTestUser::find(1));
$this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::withTrashed()->find(1)->deleted_at);
$this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::withTrashed()->find(1)->deleted_at);
Expand Down

0 comments on commit 90a844d

Please sign in to comment.