2017-25 © Pedro Peláez
 

library yii2-relational-set

Represents Yii2 m2m junction relation as PK-array field

image

siddthartha/yii2-relational-set

Represents Yii2 m2m junction relation as PK-array field

  • Wednesday, April 5, 2017
  • by siddthartha
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

yii2-relational-set

Represents Yii2 m2m junction relation as array field. Stores it's changes as difference without cleaning relation., (*1)

Installation

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

Either run, (*3)

$ composer require siddthartha/yii2-relational-set

or add, (*4)

"siddthartha/yii2-relational-set": "*"

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

Usage

Host model


class Host extends \yii\db\ActiveRecord { public $_slaves; /** * {@inheritdoc} */ public function behaviors() { return [ 'sets' => [ 'class' => \siddthartha\behaviors\RelationalSetBehavior::class, 'attributes' => [ '_slaves' => 'slaves', ], ], ]; } /** * @return \yii\db\ActiveQueryInterface */ public function getSlaves() { return $this->hasMany(Slave::class, ['id' => 'id_slave']) ->viaTable(HostSlave::tableName(), ['id_host' => 'id']) ->indexBy('id'); } }

View code example

    <?=$form->field( $model, '_slaves')->checkboxList(/*...*/)?>

Any changes to relation (junction table) will be executed as insert and/or update the needed difference only!, (*6)

The Versions

05/04 2017

dev-master

9999999-dev

Represents Yii2 m2m junction relation as PK-array field

  Sources   Download

The Requires

 

by Anton Sadovnikoff

02/04 2017

dev-dev

dev-dev

Represents Yii2 m2m junction relation as PK-array field

  Sources   Download

The Requires

 

by Anton Sadovnikoff