1

I have to display history of changes that are made in my app (like update, insert->who did it , what field changed and when). I am using laravel 4 and I also downloaded this. But the problem is that I am not clear of how to use it. Where to put the folder VentureCraft ? and how to get username or id of the person who did the action. Is there any other way to keep track of history in laravel?

EDIT:

Car model

namespace MyApp\Models;

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

View

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

and it shows : Undefined variable: description

Am i missing something in controller?

menjaraz
  • 7,551
  • 4
  • 41
  • 81
  • I should think there are install instructions that go with that repository? – halfer May 14 '14 at 15:31
  • Where is `$description` coming from? Is that a field on the `Car` model? Instead, try just `$car->revisionHistory as $history` – Jeff Lambert May 14 '14 at 18:55
  • @watcher Description is a field in Car model. I also tried $car->revisionHistory as $history and it shows undefined variable $car. where should i declare it? –  May 15 '14 at 07:16
  • Can you update your question with the relevant route you're trying to hit from your routes.php and the controller method? I don't think you're actually loading a `$car` instance but there's not quite enough information here yet. – Jeff Lambert May 15 '14 at 08:13
  • @ watcher http://stackoverflow.com/questions/23672101/trait-venturecraft-revisionable-revisionabletrait-not-found –  May 15 '14 at 08:20
  • i made a new question pls take a look, I am stuck –  May 15 '14 at 08:20

1 Answers1

0

Check out the README, it looks fairly self explanatory. Install with composer, migrate, then use the RevisionableTrait in your models that you wish to keep the update history of. You can should then be able to get the history of an object with:

 $object->revisionHistory;

They even have a simple example of usage within a blade template:

@foreach($account->revisionHistory as $history )
    <li>{{ $history->userResponsible()->first_name }} changed {{ $history->fieldName() }} from {{ $history->oldValue() }} to {{ $history->newValue() }}</li>
@endforeach
Jeff Lambert
  • 24,395
  • 4
  • 69
  • 96
  • yes but it showed errors. I think I was doing something wrong because instructions aren't very clear. Pls could you edit your answer step by step what should I do. I mean in wich folder should i put VentureCraft and then about loading I wasn't clear –  May 14 '14 at 17:59
  • how about you update the question with what you already tried? I think it would be a lot easier to understand whats going wrong for you in this instance. I would vote to reopen if you provide us with a better picture of the steps you've already taken to try and install this package. See also: http://stackoverflow.com/help/closed-questions – Jeff Lambert May 14 '14 at 18:21
  • I'm not exactly sure for instance what 'VentureCraft' folder you're talking about. Do you have composer installed? If so, just add `"venturecraft/revisionable": "1.*",` to your composer.json file and issue `composer update` command (or `php composer.phar update`) from the project root and that is all that is required in order to install the src files for the package. – Jeff Lambert May 14 '14 at 18:24