protected function addRelation()
    {
        if ($this->relationType == 'hasAndBelongsToMany')
        {
            $junction = $this->getJunction();

            try
            {
                Validate::table($junction)->exists();
            }
            catch (dbException $e)
            {
                Database::create($junction, [
                    $this->tables['local'] . '_id'   => 'integer',
                    $this->tables['foreign'] . '_id' => 'integer',
                ]);

                $this->insertRelationData($junction, $this->tables['local'], 'hasMany', [
                    'local'   => $this->tables['local'] . '_id',
                    'foreign' => $this->keys['local']
                ]);

                $this->insertRelationData($junction, $this->tables['foreign'], 'hasMany', [
                    'local'   => $this->tables['foreign'] . '_id',
                    'foreign' => $this->keys['foreign']
                ]);
            }
        }
        $this->insertRelationData($this->tables['local'], $this->tables['foreign'], $this->relationType, $this->keys);
    }
protected function addRelation()
    {
        if ($this->relationType == 'hasAndBelongsToMany')
        {
            $junction = $this->getJunction();

            try
            {
                Validate::table($junction)->exists();
            }
            catch (dbException $e)
            {
                Database::create($junction, [
                    $this->tables['local'] . '_id'   => 'integer',
                    $this->tables['foreign'] . '_id' => 'integer',
                ]);

                $this->insertRelationData($junction, $this->tables['local'], 'hasMany', [
                    'local'   => $this->tables['local'] . '_id',
                    'foreign' => $this->keys['local']
                ]);

                $this->insertRelationData($junction, $this->tables['foreign'], 'hasMany', [
                    'local'   => $this->tables['foreign'] . '_id',
                    'foreign' => $this->keys['foreign']
                ]);
            }
        }
        $this->insertRelationData($this->tables['local'], $this->tables['foreign'], $this->relationType, $this->keys);
    }
protected function addRelation ( ) { if ( $ this -> relationType == 'hasAndBelongsToMany' ) { $ junction = $ this -> getJunction ( ) ; try { Validate :: table ( $ junction ) -> exists ( ) ; } catch ( dbException $ e ) { Database :: create ( $ junction , [ $ this -> tables [ 'local' ] . '_id' => 'integer' , $ this -> tables [ 'foreign' ] . '_id' => 'integer' , ] ) ; $ this -> insertRelationData ( $ junction , $ this -> tables [ 'local' ] , 'hasMany' , [ 'local' => $ this -> tables [ 'local' ] . '_id' , 'foreign' => $ this -> keys [ 'local' ] ] ) ; $ this -> insertRelationData ( $ junction , $ this -> tables [ 'foreign' ] , 'hasMany' , [ 'local' => $ this -> tables [ 'foreign' ] . '_id' , 'foreign' => $ this -> keys [ 'foreign' ] ] ) ; } } $ this -> insertRelationData ( $ this -> tables [ 'local' ] , $ this -> tables [ 'foreign' ] , $ this -> relationType , $ this -> keys ) ; }
Add data to configs and create all necessary files
Add data to configs and create all necessary files