Skip to content

Commit

Permalink
Always log created and deleted events
Browse files Browse the repository at this point in the history
  • Loading branch information
weotch committed Jun 4, 2018
1 parent 59fd3c2 commit 02bfba7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions classes/Models/Change.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function shouldLogChange($action)
public static function log(Model $model, $action, Admin $admin = null)
{
// Create a new change instance
if (static::shouldWriteChange($model)) {
if (static::shouldWriteChange($model, $action)) {
$changed = static::getChanged($model, $action);
$change = static::createLog($model, $action, $admin, $changed);
}
Expand Down Expand Up @@ -125,10 +125,12 @@ public static function log(Model $model, $action, Admin $admin = null)
* besides these that changed.
*
* @param Model $model The model being touched
* @param string $action
* @return boolean
*/
static private function shouldWriteChange(Model $model)
static private function shouldWriteChange(Model $model, $action)
{
if (in_array($action, ['created', 'deleted'])) return true;
$changed_attributes = array_keys($model->getDirty());
$ignored = ['updated_at', 'public'];
$loggable = array_diff($changed_attributes, $ignored);
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/ChangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function setUp() {
}

/**
* Test that the commands page loads and all 3 changes were made
* Test that the changes page loads and all 3 changes were made
*
* @return void
*/
Expand Down

0 comments on commit 02bfba7

Please sign in to comment.