2017 © Pedro Peláez
 

yii2-extension yii2-eav-behavior

EAV behavior for ActiveRecord

image

reshik84/yii2-eav-behavior

EAV behavior for ActiveRecord

  • Tuesday, August 22, 2017
  • by reshik
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EAV-behavior, (*1)

============, (*2)

EAV behavior for ActiveRecord, (*3)

Installation, (*4)


The preferred way to install this extension is through composer., (*5)

Either run, (*6)


php composer.phar require --prefer-dist reshik84/yii2-eav-behavior "*"

or add, (*7)


"reshik84/yii2-eav-behavior": "*"

to the require section of your composer.json file., (*8)


$ php yii migrate/up --migrationPath=@vendor/reshik84/yii2-eav-behavior/migrations

Usage, (*9)


Once the extension is installed, add to your model :, (*10)


public function behaviors() { return [ 'eav' => [ 'class' => resh\eav\behaviors\EavBehavior::className(), 'model_id' => 'id' // primary key ] ]; } // list of EAV attributes public function additionalAttributes(){ return ['attr1', 'attr2', 'attr3', ... ]; } public function rules() { return [ [['attr1', 'attr2', 'attr3'], 'safe'] ]; } public function attributeLabels() { return [ 'attr1' => 'Attribute 1', 'attr2' => 'Attribute 2', 'attr3' => 'Attribute 3', ]; }

Call EAV attributes:, (*11)


$model = new Model(); $attr = $model->attr1; // get value $model->attr1 = 'some value'; // set value $model->save();

The Versions

22/08 2017

dev-master

9999999-dev

EAV behavior for ActiveRecord

  Sources   Download

BSD-3-Clause

The Requires

 

by Aleksandr Reshevskiy