Skip to content

Commit

Permalink
fix: remove the prefix of update time
Browse files Browse the repository at this point in the history
  • Loading branch information
Chance-fyi committed Dec 19, 2022
1 parent bdbf462 commit a2f1a39
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/OperationLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function generateLog($model, string $type)
case self::UPDATED:
case self::BATCH_UPDATED:
foreach ($this->getChangedAttributes($model) as $key => $value) {
$keys = explode(".", $key);
$key = end($keys);
if ($logKey === $key
|| (isset($model->ignoreLogFields) && is_array($model->ignoreLogFields) && in_array($key, $model->ignoreLogFields))) {
continue;
Expand Down
1 change: 0 additions & 1 deletion tests/model/illuminate/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@

class Base extends Model
{
public $timestamps = false;
protected $guarded = [];
}
2 changes: 2 additions & 0 deletions tests/model/illuminate/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class User extends Base
"name" => "姓名",
"sex" => "性别",
];
const CREATED_AT = "create_time";
const UPDATED_AT = "update_time";
public $ignoreLogFields = [
"create_time",
"update_time",
Expand Down

0 comments on commit a2f1a39

Please sign in to comment.