diff --git a/src/GeneratorCommand.php b/src/GeneratorCommand.php index d83357b..805aa46 100644 --- a/src/GeneratorCommand.php +++ b/src/GeneratorCommand.php @@ -2,6 +2,7 @@ namespace Luthfi\CrudGenerator; +use Illuminate\Support\Str; use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; use Illuminate\Console\DetectsApplicationNamespace; @@ -61,7 +62,7 @@ class GeneratorCommand extends Command { $modelName = is_null($modelName) ? $this->argument('name') : $modelName; $model_name = ucfirst(class_basename($modelName)); - $plural_model_name = str_plural($model_name); + $plural_model_name = Str::plural($model_name); $modelPath = $this->getModelPath($modelName); $modelNamespace = $this->getModelNamespace($modelPath); @@ -70,10 +71,10 @@ class GeneratorCommand extends Command 'full_model_name' => $modelNamespace.'\\'.$model_name, 'plural_model_name' => $plural_model_name, 'model_name' => $model_name, - 'table_name' => snake_case($plural_model_name), - 'lang_name' => snake_case($model_name), - 'collection_model_var_name' => camel_case($plural_model_name), - 'single_model_var_name' => camel_case($model_name), + 'table_name' => Str::snake($plural_model_name), + 'lang_name' => Str::snake($model_name), + 'collection_model_var_name' => Str::camel($plural_model_name), + 'single_model_var_name' => Str::camel($model_name), 'model_path' => $modelPath, ]; } diff --git a/src/Generators/LangFileGenerator.php b/src/Generators/LangFileGenerator.php index 20da9a5..65c0257 100644 --- a/src/Generators/LangFileGenerator.php +++ b/src/Generators/LangFileGenerator.php @@ -2,6 +2,8 @@ namespace Luthfi\CrudGenerator\Generators; +use Illuminate\Support\Str; + /** * Lang File Generator Class */ @@ -35,7 +37,7 @@ class LangFileGenerator extends BaseGenerator $stub = $this->files->get(__DIR__.'/../stubs/resources/lang/en/master.stub'); } - $displayModelName = ucwords(str_replace('_', ' ', snake_case($this->modelNames['model_name']))); + $displayModelName = ucwords(str_replace('_', ' ', Str::snake($this->modelNames['model_name']))); $properLangFileContent = str_replace( $this->modelNames['model_name'], diff --git a/tests/Generators/LangGeneratorTest.php b/tests/Generators/LangGeneratorTest.php index db48317..94e7b7b 100644 --- a/tests/Generators/LangGeneratorTest.php +++ b/tests/Generators/LangGeneratorTest.php @@ -3,6 +3,7 @@ namespace Tests\Generators; use Tests\TestCase; +use Illuminate\Support\Str; class LangGeneratorTest extends TestCase { @@ -13,7 +14,7 @@ class LangGeneratorTest extends TestCase $locale = config('app.locale'); $langPath = resource_path('lang/'.$locale.'/'.$this->lang_name.'.php'); - $displayModelName = ucwords(str_replace('_', ' ', snake_case($this->model_name))); + $displayModelName = ucwords(str_replace('_', ' ', Str::snake($this->model_name))); $this->assertFileExists($langPath); $langFileContent = "lang_name.'.php'); - $displayModelName = ucwords(str_replace('_', ' ', snake_case($this->model_name))); + $displayModelName = ucwords(str_replace('_', ' ', Str::snake($this->model_name))); $this->assertFileExists($langPath); $langFileContent = "full_model_name = 'App\\'.$this->model_name; $this->plural_model_name = str_plural($this->model_name); - $this->table_name = snake_case($this->plural_model_name); - $this->lang_name = snake_case($this->model_name); - $this->collection_model_var_name = camel_case($this->plural_model_name); - $this->single_model_var_name = camel_case($this->model_name); + $this->table_name = Str::snake($this->plural_model_name); + $this->lang_name = Str::snake($this->model_name); + $this->collection_model_var_name = Str::camel($this->plural_model_name); + $this->single_model_var_name = Str::camel($this->model_name); } public function tearDown()