2017 © Pedro Peláez
 

yii2-extension yii2-linkall

Behavior to handle saving multiple many to many related records in Yii2.

image

cornernote/yii2-linkall

Behavior to handle saving multiple many to many related records in Yii2.

  • Monday, August 7, 2017
  • by cornernote
  • Repository
  • 5 Watchers
  • 21 Stars
  • 11,472 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

Yii2 LinkAll

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Behavior to handle saving multiple many to many related records in Yii2., (*2)

Installation

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

Either run, (*4)

$ composer require cornernote/yii2-linkall "*"

or add, (*5)

"cornernote/yii2-linkall": "*"

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

Usage

Post Model, (*7)

class Post extends ActiveRecord
{
    public function behaviors()
    {
        return [
            \cornernote\linkall\LinkAllBehavior::className(),
        ];
    }

    public function getTags()
    {
        return $this->hasMany(Tag::className(), ['id' => 'tag_id'])
            ->viaTable('post_to_tag', ['post_id' => 'id']);
            //->via('postToTag');
    }
}

Tag Model, (*8)

class Tag extends ActiveRecord
{

}

Post Controller, (*9)

class PostController extends Controller
{
    public function actionExample()
    {
        $post = Post::findOne(1);
        $tags = [Tag::findOne(2), Tag::findOne(3)];

        $extraColumns = []; // extra columns to be saved to the many to many table
        $unlink = true; // unlink tags not in the list
        $delete = true; // delete unlinked tags

        $post->linkAll('tags', $tags, $extraColumns, $unlink, $delete);
    }
}

The Versions

07/08 2017

dev-master

9999999-dev

Behavior to handle saving multiple many to many related records in Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 link many to many linkall

20/06 2015

1.0.0

1.0.0.0

Behavior to handle saving multiple many to many related records in Yii2.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

yii2 link many to many linkall