我想使用 sofa/revisionable 包(或任何其他执行相同操作的包)跟踪 laravel 5.3 中的更改
表格如下:
item
id - primary key
title - text
item_fields
id - primary key
title - name of the field
item_field_values
item_id - foreign key to item(id)
field_id - foreign key to item_fields(id)
value - text
例子
item
1 - "John"
item_fields
1 - "email"
2 - "last login time"
3 - "balance"
item_values
1 - 1 - "john@example.com" // email
1 - 2 - "01.11.2016 11:30:03" // last login time
1 - 3 - "$38" // balance
例如,用户的余额在用户登录的同时发生变化,因此修订表将包含类似这样的内容
"For user 1 last login time changed from 01.11.2016 11:30.03 to 02.11.2016 10:20:00"
"For user 1 balance changed from $38 to $36.50"
这是两个独立的字段,彼此不相关。如果我想将它们显示为one change
,但不是不同的更改,我不能这样做,因为这些字段彼此之间没有链接。
另一个例子,新行被添加到修订表
"For user 1 balance changed from $36.5 to $33"
这是一个差异。
如何从不同字段中选择相关更改作为一个批量修订?会有很多 item_fields(数百个)。我不能依赖表created
中行的时间revisions
。
laravel 中所有与修订相关的包的问题是它们跟踪一个模型中所有字段的更改,但在我的情况下,只有一个模型(item_field_values),但一个修订/版本可以包含许多更改的行。