Skip to content

Commit

Permalink
Aded new readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammaye committed Apr 7, 2015
1 parent 945cc7f commit a0037f1
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

Yii2 edition of the [audittrail extension](https://github.com/Sammaye/audittrail).

## How to use

To use this extension you can simply add it to the model's behaviours:

use yii\db\ActiveRecord;

class Model extends ActiveRecord
{
public function behaviors()
{
return [
'sammaye\audittrail\LoggableBehaviour'
];
}
}

You can convert the entered behaviour into a key - value structure to define options for the extension for that model:

class Model extends ActiveRecord
{
public function behaviors()
{
return [
'LoggableBehaviour' => [
'class' => 'sammaye\audittrail\LoggableBehaviour',
'ignored' => ['some_field'], // This ignores fields from a selection of all fields, not needed with allowed
'allowed' => ['another_field'] // optional, not needed if you use ignore
]
];
}
}

And that is basically how to setup this extension.

## Changes

There are a couple of changes.

One of them is how to define global parameters for this extension.
Expand Down Expand Up @@ -100,7 +136,11 @@ Currently in this extension I store the fully qualified name of the class to:

## Migration

You may need to copy the migration file (within the `migrations` folder) to your `console/migrations` folder since Yii2 may not recognise it exists otherwise.
There are two ways of doing this:

- Copy the migration file (within the `migrations` folder) to your `console/migrations` folder
- Use `--migrationPath` option of the `migrate` command to
[point to the migrations folder in this repo](http://www.yiiframework.com/doc-2.0/guide-db-migrations.html#migrating-multiple-databases)

## Resources

Expand Down

0 comments on commit a0037f1

Please sign in to comment.