问题描述
我正在使用laravel 4,我想跟踪对表进行的所有交易的历史记录.我遵循了这些步骤
I am using laravel 4 and I want to keep track of history of all transactions made to a table. I followed those steps
- 在composer.json中添加了
"venturecraft/revisionable": "1.*"
-
php composer.phar update
-
在我项目的根目录中运行:
- added
"venturecraft/revisionable": "1.*"
at composer.json php composer.phar update
run in the root of my project this :
php artisan migration --package = venturecraft/revisionable
php artisan migrate --package=venturecraft/revisionable
上面写着没有什么可以迁移的"
and it says "nothing to migrate"
然后,我从应用程序/数据库文件夹中的包中复制了迁移文件,并将类名称从CreateRevisionsTable更改为类似CreateRevisionTable的内容,并且该表已在我的数据库中创建.然后,将其添加到我的Car模型中:
then i copied the migration file from the package in my app/database folder, and changed the classname from CreateRevisionsTable to something like CreateRevisionTable and the table was created in my database. Then I added this in my Car model:
1.
class Car extends Eloquent {
use \Venturecraft\Revisionable\RevisionableTrait;
protected $keepRevisionOf = array(
'Description'
);
}
然后在我的控制器中:
$description = Car::find($id);
$history = $description->revisionHistory;
然后在我看来:
@foreach($history->revisionHistory as $h )
<li>{{ $h->userResponsible()->username }} changed {{ $h->fieldName() }} from {{ $h->oldValue() }} to {{ $h->newValue() }}</li>
@endforeach
composer.json
composer.json
"require": {
"laravel/framework": "4.1.*",
"ajessup/gae-laravel": "dev-master",
"venturecraft/revisionable": "1.*"
},
结果是:
Trait 'Venturecraft\Revisionable\RevisionableTrait' not found
我想念什么?
推荐答案
尝试将composer中的项目设置为:
Try setting the item in composer to:
"venturecraft/revisionable": "~1.8"
这将匹配从1.8到2.0(但不包括2.0)的任何版本.
This will match any version from 1.8 to but not including 2.0.
此解决方案没有区别.
也许.
这篇关于找不到特质'Venturecraft \ Revisionable \ RevisionableTrait'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!