m-comscience/yii2-core-multi-value-behavior

Active Record Behaviors for Yii Framework

dev-master 2018-11-18 13:12 UTC

This package is auto-updated.

Last update: 2024-04-19 09:40:22 UTC


README

993323

Yii2 Active Record Behaviors


Installation

The preferred way to install this extension is through composer.

Install

composer require m-comscience/yii2-core-multi-value-behavior

Usage

model

use mcomscience\behaviors\CoreMultiValueBehavior;

public function behaviors()
{
    return [
        [
            'class' => CoreMultiValueBehavior::className(),
            'attributes' => [
                ActiveRecord::EVENT_BEFORE_INSERT => ['attribute1'],
                ActiveRecord::EVENT_BEFORE_UPDATE => ['attribute2'],
            ],
            'value' => function ($event) {
                return $event->sender[$event->data];
            },
        ],
    ];
}