protected function generateBelongsToManyPivotTable($name, Annotation $annotation, EntityDefinition &$entityMetadata)
    {
        $tableName = ($annotation->pivotTable)
            ? $annotation->pivotTable
            : $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse);

        $localPivotKey = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);

        $relatedPivotKey = $annotation->relatedForeignKey ?: $this->generateKey($annotation->relatedEntity);

        return new TableDefinition([
            'name' => $tableName,
            'columns' => [
                $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
                    'name' => $localPivotKey,
                    'options' => [
                        'autoIncrement' => false
                    ]
                ]),
                $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
                    'name' => $relatedPivotKey,
                    'options' => [
                        'autoIncrement' => false
                    ]
                ]),
            ]
        ]);
    }
protected function generateBelongsToManyPivotTable($name, Annotation $annotation, EntityDefinition &$entityMetadata)
    {
        $tableName = ($annotation->pivotTable)
            ? $annotation->pivotTable
            : $this->generatePivotTablename($entityMetadata['class'], $annotation->relatedEntity, $annotation->inverse);

        $localPivotKey = $annotation->localForeignKey ?: $this->generateKey($entityMetadata['class']);

        $relatedPivotKey = $annotation->relatedForeignKey ?: $this->generateKey($annotation->relatedEntity);

        return new TableDefinition([
            'name' => $tableName,
            'columns' => [
                $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
                    'name' => $localPivotKey,
                    'options' => [
                        'autoIncrement' => false
                    ]
                ]),
                $this->getModifiedPrimaryKeyColumn($entityMetadata['table'], [
                    'name' => $relatedPivotKey,
                    'options' => [
                        'autoIncrement' => false
                    ]
                ]),
            ]
        ]);
    }
protected function generateBelongsToManyPivotTable ( $ name , Annotation $ annotation , EntityDefinition & $ entityMetadata ) { $ tableName = ( $ annotation -> pivotTable ) ? $ annotation -> pivotTable : $ this -> generatePivotTablename ( $ entityMetadata [ 'class' ] , $ annotation -> relatedEntity , $ annotation -> inverse ) ; $ localPivotKey = $ annotation -> localForeignKey ? : $ this -> generateKey ( $ entityMetadata [ 'class' ] ) ; $ relatedPivotKey = $ annotation -> relatedForeignKey ? : $ this -> generateKey ( $ annotation -> relatedEntity ) ; return new TableDefinition ( [ 'name' => $ tableName , 'columns' => [ $ this -> getModifiedPrimaryKeyColumn ( $ entityMetadata [ 'table' ] , [ 'name' => $ localPivotKey , 'options' => [ 'autoIncrement' => false ] ] ) , $ this -> getModifiedPrimaryKeyColumn ( $ entityMetadata [ 'table' ] , [ 'name' => $ relatedPivotKey , 'options' => [ 'autoIncrement' => false ] ] ) , ] ] ) ; }
Generate pivot table for a belongsToMany relation.

@param string $name
@param \ProAI\Datamapper\Annotations\Annotation $annotation
@param \ProAI\Datamapper\Metadata\Definitions\Class $entityMetadata
@return \ProAI\Datamapper\Metadata\Definitions\Table
Generate pivot table for a belongsToMany relation .