Replace the fields of the model factory.

@param  string  $name
@param  string  $stub
@return string
198979
protected function replaceFields($name, &$stub)
    {
        if (empty($fillable = $this->getFillable())) {
            return str_replace('fields', '//', $stub);
        }

        $fields = 'return [';

        foreach ($fillable as $column) {
            $fields .= PHP_EOL."        '{$column}' => \$faker->word,";
        }

        return str_replace('fields', $fields.PHP_EOL.'    ];', $stub);
    }
804386
protected function replaceSchema(&$stub)
    {
        $tables = $this->getSortedTableNames();
        $stub = str_replace(
            ['{{columnOne}}', '{{columnTwo}}', '{{tableOne}}', '{{tableTwo}}'],
            array_merge(array_map('str_singular', $tables), $tables),
            $stub
        );
        return $this;
    }
592619
protected function replaceName(&$stub, $name)
    {
        $stub = str_replace('DummyTitle', $name, $stub);
        $stub = str_replace('DummyUCtitle', ucfirst(studly_case($name)), $stub);
        return $this;
    }
768183
protected function replaceClass($stub, $name)
    {
        $stub = parent::replaceClass($stub, $name);

        return str_replace('$dummy', '$' . strtolower($this->getNameInput()), $stub);
    }
1287312
protected function replaceFieldMultiple(&$stub, $isMultiple)
    {
        $stub = $this->strReplace('field_multiple', $this->getFieldMultiple($isMultiple), $stub);

        return $this;
    }
210326
protected function replaceName(&$stub)
    {
        $stub = str_replace('{{Class}}', $this->scaffoldCommandObj->getObjName('Names'), $stub);
        $stub = str_replace('{{class}}', $this->scaffoldCommandObj->getObjName('names'), $stub);
        $stub = str_replace('{{classSingle}}', $this->scaffoldCommandObj->getObjName('name'), $stub);
        $stub = str_replace('{{ClassSingle}}', $this->scaffoldCommandObj->getObjName('Name'), $stub);

        return $this;
    }
389672
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        return $this->replaceModelImport($stub)
                    ->replaceModel($stub)
                    ->replaceColumns($stub)
                    ->replaceAction($stub)
                    ->replaceFilename($stub);
    }
782705
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        $this->replaceNamespace($stub, $name);
        $this->replaceClassName($stub);
        $this->replaceSchema($stub);
        $this->replaceTableName($stub);

        return $stub;
    }
1072958
protected function replaceSchemaShow(&$stub)
    {

        if ($schema = $this->scaffoldCommandObj->option('schema')) {
            $schemaArray = (new SchemaParser)->parse($schema);
        }


        // Create view index content fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-show-content');
        $stub = str_replace('{{content_fields}}', $schema, $stub);


        return $this;
    }
1047565
protected function getShowRowHtmlField($stub, Field $field)
    {
        $this->replaceFieldName($stub, $field->name)
            ->replaceModelName($stub, $this->modelName)
            ->replaceRowFieldValue($stub, $this->getFieldValueForShow($field))
            ->replaceFieldTitle($stub, $this->getTitle($field->getLabel(), true));

        return $stub;
    }
1301955
protected function populateStub($name, $stub, $label)
    {
        $stub = str_replace('DummyClass', studly_case($name), $stub);

        // Here we will replace the label place-holders with the label specified by
        // the developer, which is useful for quickly creating a labels creation
        // or update migration from the console instead of typing it manually.
        if ( ! is_null($label))
        {
            $stub = str_replace('DummyLabel', $label, $stub);
        }

        return $stub;
    }
1316391
protected function replaceModel($stub, $model)
    {
        $model = str_replace('/', '\\', $model);

        $namespaceModel =
            trim($this->laravel->getNamespace(), '\\')
            . $this->getModuleNamespace()
            . config('stubs.namespaces.model') . '\\'
            . $model;

        if (Str::startsWith($model, '\\')) {
            $stub = str_replace('NamespacedDummyModel', trim($model, '\\'), $stub);
        } else {
            $stub = str_replace('NamespacedDummyModel', $namespaceModel, $stub);
        }

        $stub = str_replace(
            "use {$namespaceModel};\nuse {$namespaceModel};", "use {$namespaceModel};", $stub
        );

        $model = class_basename(trim($model, '\\'));
        $dummyUser = class_basename(config('auth.providers.users.model'));
        $dummyModel = Str::camel($model) === 'user' ? 'model' : Str::camel($model);

        $stub = str_replace('DummyModel', $model, $stub);
        $stub = str_replace('dummyModel', $dummyModel, $stub);
        $stub = str_replace('DummyUser', $dummyUser, $stub);

        return str_replace('dummyPluralModel', Str::plural($dummyModel), $stub);
    }
1254399
protected function replaceSchemaIndex(&$stub)
    {

        if ($schema = $this->scaffoldCommandObj->option('schema')) {
            $schemaArray = (new SchemaParser)->parse($schema);
        }


        // Create view index header fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-index-header');
        $stub = str_replace('{{header_fields}}', $schema, $stub);


        // Create view index content fields
        $schema = (new SyntaxBuilder)->create($schemaArray, $this->scaffoldCommandObj->getMeta(), 'view-index-content');
        $stub = str_replace('{{content_fields}}', $schema, $stub);


        return $this;
    }
60875
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        if ($model = $this->argument('model')) {
            if (!starts_with($model, $namespace = $this->laravel->getNamespace())) {
                $model = "{$namespace}\\{$model}";
            }
        }

        return $this->replaceModel($stub, $model);
    }
773742
protected function replaceClassName(&$stub)
    {
        $className = ucwords(camel_case($this->argument('name')));

        $stub = str_replace('{{class}}', $className, $stub);

        return $this;
    }
166740
protected function replaceNameStrings(&$stub, $name)
    {
        $table = str_plural(ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', str_replace($this->getNamespace($name).'\\', '', $name))), '_'));

        $stub = str_replace('DummyTable', $table, $stub);
        $stub = str_replace('dummy_class', strtolower(str_replace($this->getNamespace($name).'\\', '', $name)), $stub);

        return $this;
    }
800971
protected function replaceTable(&$stub, $name)
    {
        $name = ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', str_replace($this->getNamespace($name).'\\', '', $name))), '_');

        $table = Str::snake(Str::plural($name));

        $stub = str_replace('DummyTable', $table, $stub);

        return $this;
    }