mootensai / yii2-enhanced-gii

Enhanced Yii2 Gii (generator) that generates related Models & CRUD
MIT License
203 stars 98 forks source link

expandable only exclude junction table #129

Open kidzen opened 7 years ago

kidzen commented 7 years ago

should only exclude junction table from expandable

kidzen commented 7 years ago

!empty($fk) will skip parent table that does not have any parent to have children to be excluded from generate this expanded column.

        $this->createTable('{{%parent}}', [
            'id' => $this->primaryKey(),
            'name' => $this->string(),
        ]);
        $this->createTable('{{%child}}', [
            'id' => $this->primaryKey(),
            'parent_id' => $this->integer(),
            'name' => $this->string(),
        ]);
        $this->addForeignKey('fk1','{{child}}','parent_id','{{parent}}','id');

use this, and see parent/index..it will not be expanded...instead, use

sizeof($tableSchema->primaryKey) < 2