File tree 2 files changed +18
-3
lines changed
src/Illuminate/Database/Eloquent
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,15 @@ protected function runSoftDelete()
60
60
{
61
61
$ query = $ this ->newQueryWithoutScopes ()->where ($ this ->getKeyName (), $ this ->getKey ());
62
62
63
- $ this ->{ $ this -> getDeletedAtColumn ()} = $ time = $ this ->freshTimestamp ();
63
+ $ time = $ this ->freshTimestamp ();
64
64
65
- $ query ->update ([$ this ->getDeletedAtColumn () => $ this ->fromDateTime ($ time )]);
65
+ $ this ->{$ this ->getDeletedAtColumn ()} = $ time ;
66
+ $ this ->{$ this ->getUpdatedAtColumn ()} = $ time ;
67
+
68
+ $ query ->update ([
69
+ $ this ->getDeletedAtColumn () => $ this ->fromDateTime ($ time ),
70
+ $ this ->getUpdatedAtColumn () => $ this ->fromDateTime ($ time )
71
+ ]);
66
72
}
67
73
68
74
/**
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ public function testDeleteSetsSoftDeletedColumn()
19
19
// $model->shouldReceive('newQuery')->andReturn($query = m::mock('StdClass'));
20
20
$ model ->shouldReceive ('newQueryWithoutScopes ' )->andReturn ($ query = m::mock ('StdClass ' ));
21
21
$ query ->shouldReceive ('where ' )->once ()->with ('id ' , 1 )->andReturn ($ query );
22
- $ query ->shouldReceive ('update ' )->once ()->with (['deleted_at ' => 'date-time ' ]);
22
+ $ query ->shouldReceive ('update ' )->once ()->with ([
23
+ 'deleted_at ' => 'date-time ' ,
24
+ 'updated_at ' => 'date-time '
25
+ ]);
23
26
$ model ->delete ();
24
27
25
28
$ this ->assertInstanceOf ('Carbon\Carbon ' , $ model ->deleted_at );
@@ -53,6 +56,7 @@ class DatabaseSoftDeletingTraitStub
53
56
{
54
57
use \Illuminate \Database \Eloquent \SoftDeletes;
55
58
public $ deleted_at ;
59
+ public $ updated_at ;
56
60
57
61
public function newQuery ()
58
62
{
@@ -93,4 +97,9 @@ public function fromDateTime()
93
97
{
94
98
return 'date-time ' ;
95
99
}
100
+
101
+ public function getUpdatedAtColumn ()
102
+ {
103
+ return defined ('static::UPDATED_AT ' ) ? static ::UPDATED_AT : 'updated_at ' ;
104
+ }
96
105
}
You can’t perform that action at this time.
0 commit comments