2017 © Pedro Peláez
 

library change-log-behavior

Simple changelog behavior for yii2 models

image

cranky4/change-log-behavior

Simple changelog behavior for yii2 models

  • Friday, July 13, 2018
  • by Cranky4
  • Repository
  • 1 Watchers
  • 2 Stars
  • 977 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 20 Versions
  • 5 % Grown

The README.md

Changelog Behavior simplified(v.1.0.0)

Simple behavior for your yii2-models, (*1)

Installation

1- Install package via composer:, (*2)

composer require cranky4/change-log-behavior "*"

2- Run migrations:, (*3)

yii migrate --migrationPath=@vendor/cranky4/change-log-behavior/src/migrations

Usage

1- Add ChangeLogBehavior to any model or active record:, (*4)

public function behaviors()
{
    return [
        ...
        [
            'class' => ChangeLogBehavior::className(),
            'excludedAttributes' => ['updated_at'],
        ],
        ...
    ];
}

Attention: Behavior watches to "safe" attributes only. Add attributes into excludedAttributes if you don't want to log its changes., (*5)

2- Add ChangeLogList to view:, (*6)

 echo ChangeLogList::widget([
     'model' => $model,
 ])

3- Add custom log:, (*7)

$model->addCustomLog('hello world!', 'hello_type')

Example

Model Post, (*8)

/**
 * @propertu int id
 * @property int created_at
 * @property int updated_at
 * @property string title
 * @property int rating
 */
class Post extends yii\db\ActiveRecord {

    /**
     *  @inheritdoc
     */
    public function behaviors()
    {
        return [
            [
                'class' => ChangeLogBehavior::class,
                'excludedAttributes' => ['created_at','updated_at'],
            ]
        ];
    }

}

View post/view.php, (*9)

use cranky4\ChangeLogBahavior\ListWidget as ChangeLogList;
use app\models\Post;

/**
 *  @var Post $model
 */
echo DetailView::widget([
    'model' => $model,
    'attributes' => [
        'id',
        'title',
        'rating',
        'created_at:datetime',
        'updated_at:datetime',
    ],
]);

echo ChangeLogList::widget([
    'model' => $model,
]);

The Versions

13/07 2018

dev-master

9999999-dev

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

13/07 2018

1.0.6

1.0.6.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

12/07 2018

1.0.5

1.0.5.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

12/07 2018

1.0.4

1.0.4.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

12/07 2018

1.0.3

1.0.3.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

11/07 2018

1.0.2

1.0.2.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

11/07 2018

1.0.1

1.0.1.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

11/07 2018

1.0.0

1.0.0.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

07/12 2016

0.1.4

0.1.4.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

05/12 2016

0.1.3

0.1.3.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

05/12 2016

0.1.2

0.1.2.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.1.0

0.1.0.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.1.1

0.1.1.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.0.5

0.0.5.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.0.6

0.0.6.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.0.7

0.0.7.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

02/12 2016

0.0.8

0.0.8.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

27/09 2016

0.0.4

0.0.4.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

19/09 2016

0.0.3

0.0.3.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog

18/07 2016

0.0.2

0.0.2.0

Simple changelog behavior for yii2 models

  Sources   Download

MIT

The Requires

 

by Alexander Shander

yii2 changelog