private function addFields($modelData)
    {
        // Default primary key
        $fields = $this->tab(3) . "\$table->increments('id');" . PHP_EOL . PHP_EOL;

        // Check primary key
        foreach ($modelData->fields as $field)
        {
            if ($field->index == 'primary')
            {
                $fields = '';
                break;
            }
        }

        foreach ($modelData->fields as $field)
        {
            $parsedModifiers = '';

            // Check modifiers
            if (!empty($field->modifiers))
            {
                $modifiersArray = explode(':', $field->modifiers);

                foreach ($modifiersArray as $modifier)
                {
                    $modifierAndValue = explode(',', $modifier);

                    if (count($modifierAndValue) == 2)
                    {
                        $parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')';
                    }
                    else
                    {
                        $parsedModifiers .= '->' . $modifierAndValue[0] . '()';
                    }
                }
            }

            // Check indexes
            if ($field->index != 'none')
            {
                $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index);
            }
            else
            {
                $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers);
            }

            // Check foreign key
            if (!empty($field->foreignKey))
            {
                $foreignKey = explode(':', $field->foreignKey);
                $fields .= sprintf($this->tab(3) . "\$table->foreign('%s')->references('%s')->on('%s');" . PHP_EOL . PHP_EOL, $field->name, $foreignKey[0], $foreignKey[1]);
            }
        }

        $fields .= PHP_EOL . $this->tab(3) . "\$table->timestamps();" . PHP_EOL;

        $this->stub = str_replace('{{fields}}', $fields, $this->stub);

        return $this;
    }
private function addFields($modelData)
    {
        // Default primary key
        $fields = $this->tab(3) . "\$table->increments('id');" . PHP_EOL . PHP_EOL;

        // Check primary key
        foreach ($modelData->fields as $field)
        {
            if ($field->index == 'primary')
            {
                $fields = '';
                break;
            }
        }

        foreach ($modelData->fields as $field)
        {
            $parsedModifiers = '';

            // Check modifiers
            if (!empty($field->modifiers))
            {
                $modifiersArray = explode(':', $field->modifiers);

                foreach ($modifiersArray as $modifier)
                {
                    $modifierAndValue = explode(',', $modifier);

                    if (count($modifierAndValue) == 2)
                    {
                        $parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')';
                    }
                    else
                    {
                        $parsedModifiers .= '->' . $modifierAndValue[0] . '()';
                    }
                }
            }

            // Check indexes
            if ($field->index != 'none')
            {
                $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index);
            }
            else
            {
                $fields .= sprintf($this->tab(3) . "\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers);
            }

            // Check foreign key
            if (!empty($field->foreignKey))
            {
                $foreignKey = explode(':', $field->foreignKey);
                $fields .= sprintf($this->tab(3) . "\$table->foreign('%s')->references('%s')->on('%s');" . PHP_EOL . PHP_EOL, $field->name, $foreignKey[0], $foreignKey[1]);
            }
        }

        $fields .= PHP_EOL . $this->tab(3) . "\$table->timestamps();" . PHP_EOL;

        $this->stub = str_replace('{{fields}}', $fields, $this->stub);

        return $this;
    }
private function addFields ( $ modelData ) { // Default primary key $ fields = $ this -> tab ( 3 ) . "\$table->increments('id');" . PHP_EOL . PHP_EOL ; // Check primary key foreach ( $ modelData -> fields as $ field ) { if ( $ field -> index == 'primary' ) { $ fields = '' ; break ; } } foreach ( $ modelData -> fields as $ field ) { $ parsedModifiers = '' ; // Check modifiers if ( ! empty ( $ field -> modifiers ) ) { $ modifiersArray = explode ( ':' , $ field -> modifiers ) ; foreach ( $ modifiersArray as $ modifier ) { $ modifierAndValue = explode ( ',' , $ modifier ) ; if ( count ( $ modifierAndValue ) == 2 ) { $ parsedModifiers .= '->' . $ modifierAndValue [ 0 ] . '(' . $ modifierAndValue [ 1 ] . ')' ; } else { $ parsedModifiers .= '->' . $ modifierAndValue [ 0 ] . '()' ; } } } // Check indexes if ( $ field -> index != 'none' ) { $ fields .= sprintf ( $ this -> tab ( 3 ) . "\$table->%s('%s')%s->%s();" . PHP_EOL , $ field -> type -> db , $ field -> name , $ parsedModifiers , $ field -> index ) ; } else { $ fields .= sprintf ( $ this -> tab ( 3 ) . "\$table->%s('%s')%s;" . PHP_EOL , $ field -> type -> db , $ field -> name , $ parsedModifiers ) ; } // Check foreign key if ( ! empty ( $ field -> foreignKey ) ) { $ foreignKey = explode ( ':' , $ field -> foreignKey ) ; $ fields .= sprintf ( $ this -> tab ( 3 ) . "\$table->foreign('%s')->references('%s')->on('%s');" . PHP_EOL . PHP_EOL , $ field -> name , $ foreignKey [ 0 ] , $ foreignKey [ 1 ] ) ; } } $ fields .= PHP_EOL . $ this -> tab ( 3 ) . "\$table->timestamps();" . PHP_EOL ; $ this -> stub = str_replace ( '{{fields}}' , $ fields , $ this -> stub ) ; return $ this ; }
Add fields.

@param $modelData

@return $this
Add fields .