1

我必须显示在我的应用程序中所做的更改历史记录(例如更新、插入-> 执行者、更改的字段和时间)。我正在使用 laravel 4,我也下载了这个。但问题是我不清楚如何使用它。将文件夹 VentureCraft 放在哪里?以及如何获取执行该操作的人的用户名或 ID。有没有其他方法可以跟踪 laravel 中的历史记录?

编辑:

汽车模型

namespace MyApp\Models;

class Car extends Eloquent {
    use \Venturecraft\Revisionable\RevisionableTrait;
}

看法

@foreach($description->revisionHistory as $history )
    <li>{{ $history->userResponsible()->username }} changed {{ $history->fieldName() }} from {{ $history->oldValue() }} to {{ $history->newValue() }}</li>
@endforeach

它显示:未定义的变量:描述

我在控制器中遗漏了什么吗?

4

1 回答 1

0

查看自述文件,它看起来相当不言自明。使用 composer 安装,迁移,然后RevisionableTrait在您希望保留更新历史记录的模型中使用。然后,您应该能够通过以下方式获取对象的历史记录:

 $object->revisionHistory;

他们甚至在刀片模板中提供了一个简单的使用示例:

@foreach($account->revisionHistory as $history )
    <li>{{ $history->userResponsible()->first_name }} changed {{ $history->fieldName() }} from {{ $history->oldValue() }} to {{ $history->newValue() }}</li>
@endforeach
于 2014-05-14T15:40:45.270 回答