Build the model class with the given name.

@param  string  $name

@return string
358629
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        $viewPath = $this->option('view-path') ? $this->option('view-path') . '.' : '';
        $crudName = strtolower($this->option('crud-name'));
        $crudNameSingular = str_singular($crudName);
        $modelName = $this->option('model-name');
        $routeGroup = ($this->option('route-group')) ? $this->option('route-group') . '/' : '';

        $validationRules = '';
        if ($this->option('required-fields') != '') {
            $validationRules = "\$this->validate(\$request, " . $this->option('required-fields') . ");\n";
        }

        return $this->replaceNamespace($stub, $name)
            ->replaceViewPath($stub, $viewPath)
            ->replaceCrudName($stub, $crudName)
            ->replaceCrudNameSingular($stub, $crudNameSingular)
            ->replaceModelName($stub, $modelName)
            ->replaceRouteGroup($stub, $routeGroup)
            ->replaceValidationRules($stub, $validationRules)
            ->replaceClass($stub, $name);
    }
690722
public function setModelName($name)
    {
        $this->_modelName = $name;
        $nameParts = explode("\\", $name);
        $controllerName = end($nameParts);
        $nameParts = Text::camelCaseToSeparator($controllerName, '#');
        $nameParts = explode('#', $nameParts);

        $final = Text::plural(strtolower(array_pop($nameParts)));
        $nameParts[] = ucfirst($final);
        $this->set('modelPlural', lcfirst(implode('', $nameParts)));
        $this->set('modelSingular', lcfirst($controllerName));
        return $this;
    }
452722
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        $viewPath = $this->option('view-path') ? $this->option('view-path') . '.' : '';
        $crudName = strtolower($this->option('crud-name'));
        $crudNameSingular = str_singular($crudName);
        $modelName = $this->option('model-name');
        $modelNamespace = $this->option('model-namespace');
        $routeGroup = ($this->option('route-group')) ? $this->option('route-group') . '/' : '';
        $routePrefix = ($this->option('route-group')) ? $this->option('route-group') : '';
        $routePrefixCap = ucfirst($routePrefix);
        $perPage = intval($this->option('pagination'));
        $viewName = snake_case($this->option('crud-name'), '-');
        $fields = $this->option('fields');
        $validations = rtrim($this->option('validations'), ';');

        $validationRules = '';
        if (trim($validations) != '') {
            $validationRules = "\$this->validate(\$request, [";

            $rules = explode(';', $validations);
            foreach ($rules as $v) {
                if (trim($v) == '') {
                    continue;
                }

                // extract field name and args
                $parts = explode('#', $v);
                $fieldName = trim($parts[0]);
                $rules = trim($parts[1]);
                $validationRules .= "\n\t\t\t'$fieldName' => '$rules',";
            }

            $validationRules = substr($validationRules, 0, -1); // lose the last comma
            $validationRules .= "\n\t\t]);";
        }

        if (\App::VERSION() < '5.3') {
            $snippetUp = <<<EOD
        if (\$request->hasFile('{{fieldName}}')) {
            \$file = \$request->file('{{fieldName}}');
            \$fileName = str_random(40) . '.' . \$file->getClientOriginalExtension();
            \$destinationPath = storage_path('/app/public/uploads');
            \$file->move(\$destinationPath, \$fileName);
            \$requestData['{{fieldName}}'] = 'uploads/' . \$fileName;
        }
EOD;
        } else {
            $snippetCreateOne = <<<EOD
        if (\$request->has('{{fieldName}}')) {
            \${{fieldName}}Name = str_random(40) . '.' . \$request->{{fieldName}}->extension();
            \$requestData['{{fieldName}}'] = \${{fieldName}}Name;
        }
EOD;
            $snippetCreateTwo = <<<EOD
        if (\$request->has('{{fieldName}}')) {
            \$path = '/uploads/{{crudName}}/' . \$store->id . '/';
            Storage::makeDirectory(\$path );
            Image::make(\$request->{{fieldName}})->resize(120, 120, function (\$constraint) {
                \$constraint->aspectRatio();
            })->save(public_path(\$path . \${{fieldName}}Name));
            Image::make(\$request->{{fieldName}})->resize(300, 300, function (\$constraint) {
                \$constraint->aspectRatio();
            })->save(public_path(\$path . 'big' . \${{fieldName}}Name));
        }
EOD;
            $snippetUp = <<<EOD
        if (\$request->has('{{fieldName}}')) {
            \${{fieldName}}Name = str_random(40) . '.' . \$request->{{fieldName}}->extension();
            \$requestData['{{fieldName}}'] = \${{fieldName}}Name;
            \$path = '/uploads/{{crudName}}/' . \$up->id . '/';
            if (!empty(\$up->{{fieldName}})) {
                Storage::delete(\$path . \$up->{{fieldName}});
                Storage::delete(\$path . 'big' . \$up->{{fieldName}});
            }
            Storage::makeDirectory(\$path );
            Image::make(\$request->{{fieldName}})->resize(120, 120, function (\$constraint) {
                \$constraint->aspectRatio();
            })->save(public_path(\$path . \${{fieldName}}Name));
            Image::make(\$request->{{fieldName}})->resize(300, 300, function (\$constraint) {
                \$constraint->aspectRatio();
            })->save(public_path(\$path . 'big' . \${{fieldName}}Name));
        }
EOD;
            $snippetDelPicture = <<<EOD
        if (!empty(\$del->{{fieldName}})) {
            \$path = '/uploads/{{crudName}}/' . \$del->id . '/';
                Storage::deleteDirectory(\$path);
        }
EOD;
        }


        $fieldsArray = explode(';', $fields);
        $fileSnippetCreateOne = '';
        $fileSnippetCreateTwo = '';
        $fileSnippetUp = '';
        $fileSnippetDelPicture = '';
        $whereSnippet = '';

        if ($fields) {
            $x = 0;
            foreach ($fieldsArray as $index => $item) {
                $itemArray = explode('#', $item);

                if (trim($itemArray[1]) == 'file') {
                    $fileSnippetCreateOne .= str_replace(['{{fieldName}}', '{{crudName}}', '{{modelName}}'], [trim($itemArray[0]), $crudName, $modelName], $snippetCreateOne) . "\n";
                    $fileSnippetCreateTwo .= str_replace(['{{fieldName}}', '{{crudName}}', '{{modelName}}'], [trim($itemArray[0]), $crudName, $modelName], $snippetCreateTwo) . "\n";
                    $fileSnippetUp .= str_replace(['{{fieldName}}', '{{crudName}}', '{{modelName}}'], [trim($itemArray[0]), $crudName, $modelName], $snippetUp) . "\n";
                    $fileSnippetDelPicture .= str_replace(['{{fieldName}}', '{{crudName}}', '{{modelName}}'], [trim($itemArray[0]), $crudName, $modelName], $snippetDelPicture) . "\n";
                }

                $fieldName = trim($itemArray[0]);

                $whereSnippet .= ($index == 0) ? "where('$fieldName', 'LIKE', \"%\$keyword%\")" . "\n                " : "->orWhere('$fieldName', 'LIKE', \"%\$keyword%\")" . "\n                ";
            }

            $whereSnippet .= "->";
        }

        return $this->replaceNamespace($stub, $name)
            ->replaceViewPath($stub, $viewPath)
            ->replaceViewName($stub, $viewName)
            ->replaceCrudName($stub, $crudName)
            ->replaceCrudNameSingular($stub, $crudNameSingular)
            ->replaceModelName($stub, $modelName)
            ->replaceModelNamespace($stub, $modelNamespace)
            ->replaceModelNamespaceSegments($stub, $modelNamespace)
            ->replaceRouteGroup($stub, $routeGroup)
            ->replaceRoutePrefix($stub, $routePrefix)
            ->replaceRoutePrefixCap($stub, $routePrefixCap)
            ->replaceValidationRules($stub, $validationRules)
            ->replacePaginationNumber($stub, $perPage)
            ->replaceFileSnippetCreateOne($stub, $fileSnippetCreateOne)
            ->replaceFileSnippetCreateTwo($stub, $fileSnippetCreateTwo)
            ->replaceFileSnippetUp($stub, $fileSnippetUp)
            ->replaceFileSnippetDelPicture($stub, $fileSnippetDelPicture)
            ->replaceWhereSnippet($stub, $whereSnippet)
            ->replaceClass($stub, $name);
    }
438226
protected function buildTranslation($name)
    {
        $name = $this->getRouteName($name);
        $name = array_last(explode('.', $name));
        $name = str_replace('_', ' ', $name);

        $replace = [
            'dummy_model_plural_variable' => $name,
            'dummy_model_variable' => str_singular($name),
        ];

        return str_replace(array_keys($replace), array_values($replace), $this->files->get($this->getTranslationStub()));
    }
1200988
protected function buildClass($name): string
    {
        $event = $this->option('event');

        if (! starts_with($event, [
            $this->rootNamespace(),
            'Illuminate',
            '\\',
        ])) {
            $event = $this->rootNamespace().'Events\\'.$event;
        }

        $stub = str_replace(
            'DummyEvent', class_basename($event), $this->defaultBuildClass($name)
        );

        return str_replace(
            'DummyFullEvent', $event, $stub
        );
    }
449170
protected function buildClass($name)
    {

        $stub = parent::buildClass($name);

        $this->replaceEndpoint($stub, $this->argument('endpoint'));

        if (! is_null($this->option('esi-version')))
            $this->replaceVersion($stub, $this->option('esi-version'));

        if (! is_null($this->option('scope')))
            $this->replaceScope($stub, $this->option('scope'));

        return $stub;
    }
1255297
protected function getPropertyClassName($name)
    {
        $name = ucfirst($name);
        if (!$this->php7ClassNames) {
            return $name;
        }

        if (substr($name, -8) == 'Property') {
            return $name;
        }

        return $name.'Property';
    }
1337455
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        return $this->option('parent')
                        ? $this->replaceNamespace($stub, $name)->replaceParentClass($stub)->replaceParentFqcn($stub)->replaceClass($stub, $name)
                        : $this->replaceNamespace($stub, $name)->replaceClass($stub, $name);
    }
5680
public static function getClass(string $name)
    {
        if (!isset(static::$classes[$name])) {
            throw new ArchException('Unable to find class from key [' . $name . ']');
        }
        return static::$classes[$name];
    }
660627
public function getClassName(string $name) : string
    {
        $name = str_replace("/", "\\", $name);
        $name = explode("\\", $name);
        $name = array_pop($name);
        $name = $this->removeNoneAlpherNumeric($name);
        return $name;
    }
239422
protected function buildClass($name)
    {
        $stub = parent::buildClass($name);

        $event = $this->option('event');

        //
        $namespace = $this->container->getNamespace();

        if (! Str::startsWith($event, $namespace)) {
            $event = $namespace .'Events\\' .$event;
        }

        $stub = str_replace(
            '{{event}}', class_basename($event), $stub
        );

        $stub = str_replace(
            '{{fullEvent}}', $event, $stub
        );

        return $stub;
    }
668616
protected function getModelValueAttribute($name)
    {
        if (is_object($this->model))
        {
            return object_get($this->model, $this->transformKey($name));
        }
        elseif (is_array($this->model))
        {
            return array_get($this->model, $this->transformKey($name));
        }
    }
1106066
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        $table = $this->option('table') ?: $this->argument('name');
        $fillable = $this->option('fillable');
        $primaryKey = $this->option('pk');
        $relationships = trim($this->option('relationships')) != '' ? explode(';', trim($this->option('relationships'))) : [];
        $softDeletes = $this->option('soft-deletes');

        if (!empty($primaryKey)) {
            $primaryKey = <<<EOD
/**
    * The database primary key value.
    *
    * @var string
    */
    protected \$primaryKey = '$primaryKey';
EOD;
        }

        $ret = $this->replaceNamespace($stub, $name)
            ->replaceTable($stub, $table)
            ->replaceFillable($stub, $fillable)
            ->replacePrimaryKey($stub, $primaryKey)
            ->replaceSoftDelete($stub, $softDeletes);

        foreach ($relationships as $rel) {
            // relationshipname#relationshiptype#args_separated_by_pipes
            // e.g. employees#hasMany#App\Employee|id|dept_id
            // user is responsible for ensuring these relationships are valid
            $parts = explode('#', $rel);

            if (count($parts) != 3) {
                continue;
            }

            // blindly wrap each arg in single quotes
            $args = explode('|', trim($parts[2]));
            $argsString = '';
            foreach ($args as $k => $v) {
                if (trim($v) == '') {
                    continue;
                }

                $argsString .= "'" . trim($v) . "', ";
            }

            $argsString = substr($argsString, 0, -2); // remove last comma

            $ret->createRelationshipFunction($stub, trim($parts[0]), trim($parts[1]), $argsString);
        }

        $ret->replaceRelationshipPlaceholder($stub);

        return $ret->replaceClass($stub, $name);
    }
170221
protected function buildClass($name)
    {
        $stub = $this->files->get($this->getStub());

        // examples used for the placeholders is for 'foo.bar'

        // App\Foo
        $stub = str_replace('{{namespace}}', $this->getNamespace($name), $stub);

        // App\
        $stub = str_replace('{{rootNamespace}}', $this->getAppNamespace(), $stub);

        // Bar
        $stub = str_replace('{{class}}', $this->getClassName(), $stub);

        $url = $this->getUrl(); // /foo/bar

        // /foo/bar
        $stub = str_replace('{{url}}', $this->getUrl(), $stub);

        // bars
        $stub = str_replace('{{collection}}', $this->getCollectionName(), $stub);

        // Bars
        $stub = str_replace('{{collectionUpper}}', $this->getCollectionUpperName(), $stub);

        // Bar
        $stub = str_replace('{{model}}', $this->getModelName(), $stub);

        // Bar
        $stub = str_replace('{{resource}}', $this->resource, $stub);

        // bar
        $stub = str_replace('{{resourceLowercase}}', $this->resourceLowerCase, $stub);

        // ./resources/views/foo/bar.blade.php
        $stub = str_replace('{{path}}', $this->getPath(''), $stub);

        // foos.bars
        $stub = str_replace('{{view}}', $this->getViewPath($this->getUrl(false)), $stub);

        // bars
        $stub = str_replace('{{table}}', $this->getTableName($url), $stub);

        // event - listeners
        $event = $this->option('event');

        if (!Str::startsWith($event, $this->laravel->getNamespace()) && !Str::startsWith($event,
                'Illuminate')
        ) {
            $event = $this->laravel->getNamespace() . 'Events\\' . $event;
        }

        // event class name
        $stub = str_replace('{{event}}', class_basename($event), $stub);

        // event with namespace
        $stub = str_replace('{{eventAndNamespace}}', $event, $stub);

        return $stub;
    }
233382
public function controllerClassNameStrategy($name)
    {
        $names = explode('_', $name);
        $names = array_map('ucfirst', $names);
        return join('\\', $names) . 'Controller';
    }
704068
public function build($name, $overrides = [])
    {
        $attributes = $this->getAttributes($name, $overrides);
        $class = $this->getFixture($name)->name;

        // We'll pass off the process of creating the entity.
        // That way, folks can use different persistence layers.

        return $this->model->build($class, $attributes);
    }
682978
protected function buildClass($name)
    {
        $controllerNamespace = $this->getNamespace($name);

        $replace = [];

        if ($this->option('parent')) {
            $replace['DummyFullParentClass'] = $controllerNamespace.'Controller';
            $replace['DummyParentClass'] = class_basename($controllerNamespace.'Controller');
            $replace['parent_dummy_view'] = $this->getParentViewName($name);
            $replace['parent_dummy_route'] = $this->getParentRouteName($name);
        }
        $replace['dummy_view'] = $this->getViewName($name);
        $replace['dummy_route'] = $this->getRouteName($name);

        return str_replace(array_keys($replace), array_values($replace), parent::buildClass($name));
    }