Skip to content

Commit 02bfba7

Browse files
committed
Always log created and deleted events
1 parent 59fd3c2 commit 02bfba7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

classes/Models/Change.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function shouldLogChange($action)
9696
public static function log(Model $model, $action, Admin $admin = null)
9797
{
9898
// Create a new change instance
99-
if (static::shouldWriteChange($model)) {
99+
if (static::shouldWriteChange($model, $action)) {
100100
$changed = static::getChanged($model, $action);
101101
$change = static::createLog($model, $action, $admin, $changed);
102102
}
@@ -125,10 +125,12 @@ public static function log(Model $model, $action, Admin $admin = null)
125125
* besides these that changed.
126126
*
127127
* @param Model $model The model being touched
128+
* @param string $action
128129
* @return boolean
129130
*/
130-
static private function shouldWriteChange(Model $model)
131+
static private function shouldWriteChange(Model $model, $action)
131132
{
133+
if (in_array($action, ['created', 'deleted'])) return true;
132134
$changed_attributes = array_keys($model->getDirty());
133135
$ignored = ['updated_at', 'public'];
134136
$loggable = array_diff($changed_attributes, $ignored);

tests/Integration/ChangesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ protected function setUp() {
3737
}
3838

3939
/**
40-
* Test that the commands page loads and all 3 changes were made
40+
* Test that the changes page loads and all 3 changes were made
4141
*
4242
* @return void
4343
*/

0 commit comments

Comments
 (0)