File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed
src/Illuminate/Database/Eloquent Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -60,9 +60,15 @@ protected function runSoftDelete()
6060 {
6161 $ query = $ this ->newQueryWithoutScopes ()->where ($ this ->getKeyName (), $ this ->getKey ());
6262
63- $ this ->{ $ this -> getDeletedAtColumn ()} = $ time = $ this ->freshTimestamp ();
63+ $ time = $ this ->freshTimestamp ();
6464
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+ ]);
6672 }
6773
6874 /**
Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ public function testDeleteSetsSoftDeletedColumn()
1919 // $model->shouldReceive('newQuery')->andReturn($query = m::mock('StdClass'));
2020 $ model ->shouldReceive ('newQueryWithoutScopes ' )->andReturn ($ query = m::mock ('StdClass ' ));
2121 $ 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+ ]);
2326 $ model ->delete ();
2427
2528 $ this ->assertInstanceOf ('Carbon\Carbon ' , $ model ->deleted_at );
@@ -53,6 +56,7 @@ class DatabaseSoftDeletingTraitStub
5356{
5457 use \Illuminate \Database \Eloquent \SoftDeletes;
5558 public $ deleted_at ;
59+ public $ updated_at ;
5660
5761 public function newQuery ()
5862 {
@@ -93,4 +97,9 @@ public function fromDateTime()
9397 {
9498 return 'date-time ' ;
9599 }
100+
101+ public function getUpdatedAtColumn ()
102+ {
103+ return defined ('static::UPDATED_AT ' ) ? static ::UPDATED_AT : 'updated_at ' ;
104+ }
96105}
You can’t perform that action at this time.
0 commit comments