sammaye / yii2-audittrail Goto Github PK
View Code? Open in Web Editor NEWYii2 edition of the audit trail extension. Adds storage history of changes to the ActiveRecord model.
Yii2 edition of the audit trail extension. Adds storage history of changes to the ActiveRecord model.
Please, add here https://yadi.sk/i/NVk-gib3VB6Wtg text
"Yii2 edition of the audit trail extension. Adds storage history of changes to the ActiveRecord model"
For SEO so that upon request https://github.com/search?q=yii2+activerecord+history your extension could be found.
Why it's needed? You can just execute migrate
command with --migrationPath
option.
How can we get the value of an audit trailed attribute on particular date? For example say there is a attribute Status in a model which undergone below changes
01/01/2015 - Open
05/02/2015 - In Progress
07/04/2015 - Waiting
04/07/2015 - Closed
Similary status on other records also got changed on different dates.
Now say I want to generate a report of all the records of this model with status as on 01/04/2015. How can I achieve that?
I propose to add another column in audit trail which stores the end time stamp of that audit trail record (say endTimeStamp). So on any update we have to first search if any previous audit trail record exists for same attribute and same model and model id. If yes we have to stamp the endTimeStamp with the time stamp of new audit trail record. Now we can identify the value of status attribute of model on any date by checking timestamp <= '01/04/2015' and (endTimeStamp > '01/04/2015' or endTimeStamp is null).
Currently this behavior is storing fully qualified name of the model (for example app\models\Assignment). How can we make it to store non qualified model name Storing just Assignment instead of app\models\Assignment.
I have added the requierd line to composer.json. run composer update. In my class i have placed
public function behaviors()
{
return [
'sammaye\audittrail\LoggableBehaviour'
/_'LoggableBehavior'=> array(
'class' => 'sammaye\audittrail\LoggableBehaviour'//'site.vendor.sammaye.audittrail.LoggableBehavior',
)_/
];
}
I get the following error
Class sammaye\audittrail\LoggableBehaviour does not exist
hi i has installed yii2-audittrail but i got error Setting unknown property: sammaye\audittrail\AuditTrail::stamp if do update one of table, even though exist field stamp on tbl_audit_trail. thanks
This commit is only available on dev-master: a6a6919
But there should be also a 0.2.0 tag with this commit.
Hi how to implement this extension on RBAC ? i want log each change like auth_item, auth_assigment, auth_item_child, but i confuse where i put sammaye\audittrail\LoggableBehavior. FYI i use Yii::$app->authManager for CRUD. Thanks
Just curios ....
Hi how to installation this with composer. thanks
hi whether this extension possible to rollback old value?.. thanks
Migrations do not work on Postgresql. Migration class m161004_132206_change_action_field
*** applying m161004_132206_change_action_field
> alter column action in table tbl_audit_trail to ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL ...Exception 'yii\db\Exception' with message 'SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "NOT"
LINE 1: ...ion" TYPE ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL
^
The SQL being executed was: ALTER TABLE "tbl_audit_trail" ALTER COLUMN "action" TYPE ENUM('CHANGE', 'CREATE', 'DELETE', 'SET') NOT NULL'
What is the best way to use this plugin when some of the changed fields are related data. Currently the values are the id's of the related fields and when I display them, it of course displays the id's. What would be the best way to store what the related field's data is?
Upon saving an active record, I get a yii\base\ErrorException
of Array to string conversion
Stack trace
in /var/www/html/leadworks/protected/vendor/sammaye/yii2-audittrail/LoggableBehavior.php line 101
foreach ($oldattributes as $f => $v) {
if (array_search($f, $ignoredFields) !== false)
unset($oldattributes[$f]);
}
}
// If no difference then WHY?
// There is some kind of problem here that means "0" and 1 do not diff for array_diff so beware: stackoverflow.com/questions/12004231/php-array-diff-weirdness :S
if (count(array_diff_assoc($newattributes, $oldattributes)) <= 0)
return;
// If this is a new record lets add a CREATE notification
if ($insert) {
$this->leaveTrail(self::ACTION_CREATE);
}
// Now lets actually write the attributes
$this->auditAttributes($insert, $newattributes, $oldattributes);
In Yii2, JSON fields are converted to arrays:
This needs to be accounted for in some way.
I did not find any documentation regarding How to install this extension?
How it will work with transaction process where multiple model will be responsible for changes.
Now if i wanted to log this in one entity then how can i do it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.