public function createRelationship(
        $table,
        $relationship,
        $properties = [],
        $check_exist = false,
        $return_schema = false
    ) {
        $properties = (is_array($properties) ? $properties : []);
        $properties['name'] = $relationship;

        $fields = static::validateAsArray($properties, null, true, 'Bad data format in request.');

        $tables = [['name' => $table, 'related' => $fields]];
        $result = $this->updateSchema($tables, !$check_exist);
        $result = array_get(array_get($result, 0, []), 'related', []);

        //  Any changes here should refresh cached schema
        $this->refreshCachedTables();

        if ($return_schema) {
            return $this->describeRelationship($table, $relationship);
        }

        return $result;
    }
public function createRelationship(
        $table,
        $relationship,
        $properties = [],
        $check_exist = false,
        $return_schema = false
    ) {
        $properties = (is_array($properties) ? $properties : []);
        $properties['name'] = $relationship;

        $fields = static::validateAsArray($properties, null, true, 'Bad data format in request.');

        $tables = [['name' => $table, 'related' => $fields]];
        $result = $this->updateSchema($tables, !$check_exist);
        $result = array_get(array_get($result, 0, []), 'related', []);

        //  Any changes here should refresh cached schema
        $this->refreshCachedTables();

        if ($return_schema) {
            return $this->describeRelationship($table, $relationship);
        }

        return $result;
    }
public function createRelationship ( $ table , $ relationship , $ properties = [ ] , $ check_exist = false , $ return_schema = false ) { $ properties = ( is_array ( $ properties ) ? $ properties : [ ] ) ; $ properties [ 'name' ] = $ relationship ; $ fields = static :: validateAsArray ( $ properties , null , true , 'Bad data format in request.' ) ; $ tables = [ [ 'name' => $ table , 'related' => $ fields ] ] ; $ result = $ this -> updateSchema ( $ tables , ! $ check_exist ) ; $ result = array_get ( array_get ( $ result , 0 , [ ] ) , 'related' , [ ] ) ; //  Any changes here should refresh cached schema $ this -> refreshCachedTables ( ) ; if ( $ return_schema ) { return $ this -> describeRelationship ( $ table , $ relationship ) ; } return $ result ; }
Create a single table relationship by name and additional properties

@param string $table
@param string $relationship
@param array  $properties
@param bool   $check_exist
@param bool   $return_schema Return a refreshed copy of the schema from the database
@return array|mixed
@throws BadRequestException
@throws \Exception
Create a single table relationship by name and additional properties