jberall/yii2-statusbehavior

A behavior that set the status to 0 when the status_column is set to null. triggered on BaseActiveRecord::EVENT_BEFORE_INSERT and BaseActiveRecord::EVENT_BEFORE_UPDATE

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.03 2017-04-27 22:29 UTC

This package is not auto-updated.

Last update: 2024-11-10 04:01:50 UTC


README

A behavior that set the status to 0 when the status_column is set to null. triggered on BaseActiveRecord::EVENT_BEFORE_INSERT and BaseActiveRecord::EVENT_BEFORE_UPDATE

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist jberall/yii2-statusbehavior "*"

or add

"jberall/yii2-statusbehavior": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

    public function behaviors() {
        
        $behaviors = [

            'statusBehavior' => [
				'class' => \frontend\behaviors\StatusBehavior::className(),
				'status_column' => 'status_id',
				
			],
        ];
        return ArrayHelper::merge(parent::behaviors(),$behaviors);

    }