jobsrey / yii2-changelog
Change Log
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
Type:yii2-extension
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.0
- yiisoft/yii2-authclient: ^2.1.0
- yiisoft/yii2-bootstrap: ^2.0.0
- yiisoft/yii2-swiftmailer: ^2.0.0
Requires (Dev)
- codeception/specify: ^0.4.3
- codeception/verify: ^0.3.1
- yiisoft/yii2-codeception: ^2.0.0
This package is auto-updated.
Last update: 2024-10-24 14:48:35 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist jobsrey/yii2-changelog "*"
or add
"jobsrey/yii2-changelog": "*"
to the require section of your composer.json
file.
Usage
Once the extension is installed, simply use it in your code by :
'components' => [ ... 'changelog' => [ 'class' => 'jobsrey\changelog\ChangeLog', ],
on model
class Users extends \yii\db\ActiveRecord { public $old_attr; //old atribute ... public function afterSave($insert, $changedAttributes) { parent::afterSave($insert, $changedAttributes); if($insert){ //save log insert Yii::$app->changelog->saveLogMessage($this, $this->username.' telah dibuat!',1); } else { //save log update foreach($changedAttributes as $attr => $value){ Yii::$app->changelog->saveLogUpdateByOne($attr,$this,$this->old_attr); } } return true; } public function afterFind(){ parent::afterFind(); $this->old_attr = $this->getAttributes(); //add to compare data } }
keterangan status
- insert
- update
- delete
- only info