src/models/PropertyGroup.php
public function autoAddToObjects()
    {
        /** @var \yii\db\ActiveRecord|\DevGroup\DataStructure\traits\PropertiesTrait $modelClassName */
        $modelClassName = PropertiesHelper::classNameForApplicablePropertyModelId($this->applicable_property_model_id);
        $modelIdsWithoutGroup = $modelClassName::find()
            ->leftJoin(
                $modelClassName::bindedPropertyGroupsTable() . ' bpg',
                'bpg.model_id = id'
            )
            ->where('bpg.model_id IS NULL')
            ->select('id')
            ->column($modelClassName::getDb());

        $insertRows = array_map(
            function ($item) {
                return [
                    $item,
                    $this->id
                ];
            },
            $modelIdsWithoutGroup
        );
        if (count($insertRows) > 0) {
            $modelClassName::getDb()->createCommand()->batchInsert(
                $modelClassName::bindedPropertyGroupsTable(),
                [
                    'model_id',
                    'property_group_id',
                ],
                $insertRows
            )->execute();
        }
    }
public function autoAddToObjects()
    {
        /** @var \yii\db\ActiveRecord|\DevGroup\DataStructure\traits\PropertiesTrait $modelClassName */
        $modelClassName = PropertiesHelper::classNameForApplicablePropertyModelId($this->applicable_property_model_id);
        $modelIdsWithoutGroup = $modelClassName::find()
            ->leftJoin(
                $modelClassName::bindedPropertyGroupsTable() . ' bpg',
                'bpg.model_id = id'
            )
            ->where('bpg.model_id IS NULL')
            ->select('id')
            ->column($modelClassName::getDb());

        $insertRows = array_map(
            function ($item) {
                return [
                    $item,
                    $this->id
                ];
            },
            $modelIdsWithoutGroup
        );
        if (count($insertRows) > 0) {
            $modelClassName::getDb()->createCommand()->batchInsert(
                $modelClassName::bindedPropertyGroupsTable(),
                [
                    'model_id',
                    'property_group_id',
                ],
                $insertRows
            )->execute();
        }
    }
public function autoAddToObjects ( ) { /** @var \yii\db\ActiveRecord|\DevGroup\DataStructure\traits\PropertiesTrait $modelClassName */ $ modelClassName = PropertiesHelper :: classNameForApplicablePropertyModelId ( $ this -> applicable_property_model_id ) ; $ modelIdsWithoutGroup = $ modelClassName :: find ( ) -> leftJoin ( $ modelClassName :: bindedPropertyGroupsTable ( ) . ' bpg' , 'bpg.model_id = id' ) -> where ( 'bpg.model_id IS NULL' ) -> select ( 'id' ) -> column ( $ modelClassName :: getDb ( ) ) ; $ insertRows = array_map ( function ( $ item ) { return [ $ item , $ this -> id ] ; } , $ modelIdsWithoutGroup ) ; if ( count ( $ insertRows ) > 0 ) { $ modelClassName :: getDb ( ) -> createCommand ( ) -> batchInsert ( $ modelClassName :: bindedPropertyGroupsTable ( ) , [ 'model_id' , 'property_group_id' , ] , $ insertRows ) -> execute ( ) ; } }
Finds new applicable models and binds this group to them

@throws \yii\db\Exception Database exception is thrown on error
Finds new applicable models and binds this group to them