diff --git a/src/CrudMake.php b/src/CrudMake.php index e73c700..d9c3062 100644 --- a/src/CrudMake.php +++ b/src/CrudMake.php @@ -122,12 +122,14 @@ class CrudMake extends Command public function getIndexViewContent() { - return $this->files->get(__DIR__.'/stubs/view-index.stub'); + $stub = $this->files->get(__DIR__.'/stubs/view-index.stub'); + return $this->replaceViewDummyStrings($stub)->replaceClass($stub); } public function getFormsViewContent() { - return $this->files->get(__DIR__.'/stubs/view-forms.stub'); + $stub = $this->files->get(__DIR__.'/stubs/view-forms.stub'); + return $this->replaceViewDummyStrings($stub)->replaceClass($stub); } public function getFeatureTestContent() @@ -195,6 +197,17 @@ class CrudMake extends Command return $this; } + protected function replaceViewDummyStrings(&$stub) + { + $stub = str_replace( + ['Master', 'master', 'masters'], + [$this->modelName, strtolower($this->modelName), $this->lowerCasePluralModel], + $stub + ); + + return $this; + } + protected function replaceClass($stub) { $class = str_plural($this->modelName); diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index d3565b6..252df0d 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -15,11 +15,11 @@ class ViewsGeneratorTest extends TestCase $this->assertFileExists($indexViewPath); $indexViewContent = "@extends('layouts.app') -@section('title', trans('master.list')) +@section('title', trans('item.list')) @section('content') -{{ link_to_route('masters.index', trans('master.create'), ['action' => 'create'], ['class' => 'btn btn-success pull-right']) }} -
{{ \$editableMaster->name }}
- {!! \$errors->first('master_id', ':message') !!} + +{{ \$editableItem->name }}
+ {!! \$errors->first('item_id', ':message') !!}