diff --git a/src/stubs/controller.full.stub b/src/stubs/controller.full.stub
index 0d43fd2..c12c005 100644
--- a/src/stubs/controller.full.stub
+++ b/src/stubs/controller.full.stub
@@ -94,11 +94,9 @@ class MastersController extends Controller
'description' => 'nullable|max:255',
]);
- $routeParam = request()->only('page', 'q');
-
$singleMstr = $singleMstr->update($request->only('name', 'description'));
- return redirect()->route('masters.index', $routeParam);
+ return redirect()->route('masters.show', $singleMstr);
}
/**
diff --git a/src/stubs/test-feature-full.stub b/src/stubs/test-feature-full.stub
index e51684d..c606ba7 100644
--- a/src/stubs/test-feature-full.stub
+++ b/src/stubs/test-feature-full.stub
@@ -51,7 +51,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create(['name' => 'Testing 123']);
$this->visit(route('masters.show', $singleMstr));
- $this->click('edit-singleMstr-'.$singleMstr->id);
+ $this->click('edit-master-'.$singleMstr->id);
$this->seePageIs(route('masters.edit', $singleMstr));
$this->submitForm(trans('master.update'), [
@@ -75,7 +75,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create();
$this->visit(route('masters.edit', $singleMstr));
- $this->click('del-singleMstr-'.$singleMstr->id);
+ $this->click('del-master-'.$singleMstr->id);
$this->seePageIs(route('masters.edit', [$singleMstr, 'action' => 'delete']));
$this->press(trans('app.delete_confirm_button'));
diff --git a/src/stubs/test-feature-simple.stub b/src/stubs/test-feature-simple.stub
index 3603193..a7aa55f 100644
--- a/src/stubs/test-feature-simple.stub
+++ b/src/stubs/test-feature-simple.stub
@@ -50,7 +50,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create(['name' => 'Testing 123']);
$this->visit(route('masters.index', ['q' => '123']));
- $this->click('edit-singleMstr-'.$singleMstr->id);
+ $this->click('edit-master-'.$singleMstr->id);
$this->seePageIs(route('masters.index', ['action' => 'edit', 'id' => $singleMstr->id, 'q' => '123']));
$this->type('Master 1 name', 'name');
@@ -72,7 +72,7 @@ class ManageMastersTest extends TestCase
$singleMstr = factory(Master::class)->create();
$this->visit(route('masters.index', [$singleMstr->id]));
- $this->click('del-singleMstr-'.$singleMstr->id);
+ $this->click('del-master-'.$singleMstr->id);
$this->seePageIs(route('masters.index', ['action' => 'delete', 'id' => $singleMstr->id]));
$this->seeInDatabase('masters', [
diff --git a/src/stubs/view-edit.stub b/src/stubs/view-edit.stub
index 52d8537..22443f9 100644
--- a/src/stubs/view-edit.stub
+++ b/src/stubs/view-edit.stub
@@ -3,8 +3,38 @@
@section('title', trans('master.edit'))
@section('content')
+
+ @if (request('action') == 'delete' && $singleMstr)
+ @can('delete', $singleMstr)
+
+
{{ trans('master.delete') }}
+
+
+
{{ $singleMstr->name }}
+
+
{{ $singleMstr->description }}
+ {!! $errors->first('master_id', '
:message') !!}
+
+
+
{{ trans('app.delete_confirm') }}
+
+
+ @endcan
+ @else
{{ trans('master.edit') }}
{!! Form::model($singleMstr, ['route' => ['masters.update', $singleMstr->id],'method' => 'patch']) !!}
@@ -15,9 +45,11 @@
{!! Form::close() !!}
+@endif
@endsection
diff --git a/src/stubs/view-index-full.stub b/src/stubs/view-index-full.stub
index 90a99fb..5a24ce3 100644
--- a/src/stubs/view-index-full.stub
+++ b/src/stubs/view-index-full.stub
@@ -35,7 +35,7 @@
@foreach($mstrCollections as $key => $singleMstr)
| {{ $mstrCollections->firstItem() + $key }} |
- {{ $singleMstr->name }} |
+ {{ $singleMstr->nameLink() }} |
{{ $singleMstr->description }} |
@can('view', $singleMstr)
@@ -43,7 +43,7 @@
'masters.show',
trans('app.show'),
[$singleMstr],
- ['class' => 'btn btn-default', 'id' => 'show-master-' . $singleMstr->id]
+ ['class' => 'btn btn-default btn-xs', 'id' => 'show-master-' . $singleMstr->id]
) !!}
@endcan
|
diff --git a/src/stubs/view-index-simple.stub b/src/stubs/view-index-simple.stub
index eb020d0..11272f3 100644
--- a/src/stubs/view-index-simple.stub
+++ b/src/stubs/view-index-simple.stub
@@ -43,7 +43,7 @@
'masters.index',
trans('app.edit'),
['action' => 'edit', 'id' => $singleMstr->id] + Request::only('page', 'q'),
- ['id' => 'edit-singleMstr-' . $singleMstr->id]
+ ['id' => 'edit-master-'.$singleMstr->id]
) !!} |
@endcan
@can('delete', $singleMstr)
@@ -51,7 +51,7 @@
'masters.index',
trans('app.delete'),
['action' => 'delete', 'id' => $singleMstr->id] + Request::only('page', 'q'),
- ['id' => 'del-singleMstr-' . $singleMstr->id]
+ ['id' => 'del-master-'.$singleMstr->id]
) !!}
@endcan
diff --git a/src/stubs/view-show.stub b/src/stubs/view-show.stub
index 151784e..c116667 100644
--- a/src/stubs/view-show.stub
+++ b/src/stubs/view-show.stub
@@ -20,7 +20,8 @@
diff --git a/tests/Generators/FeatureTestGeneratorTest.php b/tests/Generators/FeatureTestGeneratorTest.php
index a472587..4ab2896 100644
--- a/tests/Generators/FeatureTestGeneratorTest.php
+++ b/tests/Generators/FeatureTestGeneratorTest.php
@@ -102,7 +102,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.show', \${$this->single_model_var_name}));
- \$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->submitForm(trans('{$this->lang_name}.update'), [
@@ -126,7 +126,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
- \$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', [\${$this->single_model_var_name}, 'action' => 'delete']));
\$this->press(trans('app.delete_confirm_button'));
@@ -245,7 +245,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.show', \${$this->single_model_var_name}));
- \$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
\$this->submitForm(trans('{$this->lang_name}.update'), [
@@ -269,7 +269,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.edit', \${$this->single_model_var_name}));
- \$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.edit', [\${$this->single_model_var_name}, 'action' => 'delete']));
\$this->press(trans('app.delete_confirm_button'));
diff --git a/tests/Generators/FullControllerGeneratorTest.php b/tests/Generators/FullControllerGeneratorTest.php
index 8219b21..ac77fe6 100644
--- a/tests/Generators/FullControllerGeneratorTest.php
+++ b/tests/Generators/FullControllerGeneratorTest.php
@@ -108,11 +108,9 @@ class {$this->plural_model_name}Controller extends Controller
'description' => 'nullable|max:255',
]);
- \$routeParam = request()->only('page', 'q');
-
\${$this->single_model_var_name} = \${$this->single_model_var_name}->update(\$request->only('name', 'description'));
- return redirect()->route('{$this->table_name}.index', \$routeParam);
+ return redirect()->route('{$this->table_name}.show', \${$this->single_model_var_name});
}
/**
@@ -244,11 +242,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
- \$routeParam = request()->only('page', 'q');
-
\$category = \$category->update(\$request->only('name', 'description'));
- return redirect()->route('categories.index', \$routeParam);
+ return redirect()->route('categories.show', \$category);
}
/**
@@ -381,11 +377,9 @@ class CategoriesController extends Controller
'description' => 'nullable|max:255',
]);
- \$routeParam = request()->only('page', 'q');
-
\$category = \$category->update(\$request->only('name', 'description'));
- return redirect()->route('categories.index', \$routeParam);
+ return redirect()->route('categories.show', \$category);
}
/**
diff --git a/tests/Generators/Simple/FeatureTestGeneratorTest.php b/tests/Generators/Simple/FeatureTestGeneratorTest.php
index ee27019..666c08b 100644
--- a/tests/Generators/Simple/FeatureTestGeneratorTest.php
+++ b/tests/Generators/Simple/FeatureTestGeneratorTest.php
@@ -101,7 +101,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.index', ['q' => '123']));
- \$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']));
\$this->type('{$this->model_name} 1 name', 'name');
@@ -123,7 +123,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
- \$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));
\$this->seeInDatabase('{$this->table_name}', [
@@ -245,7 +245,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create(['name' => 'Testing 123']);
\$this->visit(route('{$this->table_name}.index', ['q' => '123']));
- \$this->click('edit-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'edit', 'id' => \${$this->single_model_var_name}->id, 'q' => '123']));
\$this->type('{$this->model_name} 1 name', 'name');
@@ -267,7 +267,7 @@ class Manage{$this->plural_model_name}Test extends TestCase
\${$this->single_model_var_name} = factory({$this->model_name}::class)->create();
\$this->visit(route('{$this->table_name}.index', [\${$this->single_model_var_name}->id]));
- \$this->click('del-{$this->single_model_var_name}-'.\${$this->single_model_var_name}->id);
+ \$this->click('del-{$this->lang_name}-'.\${$this->single_model_var_name}->id);
\$this->seePageIs(route('{$this->table_name}.index', ['action' => 'delete', 'id' => \${$this->single_model_var_name}->id]));
\$this->seeInDatabase('{$this->table_name}', [
diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php
index f504984..1b93fee 100644
--- a/tests/Generators/Simple/ViewsGeneratorTest.php
+++ b/tests/Generators/Simple/ViewsGeneratorTest.php
@@ -59,7 +59,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.index',
trans('app.edit'),
['action' => 'edit', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
- ['id' => 'edit-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id]
+ ['id' => 'edit-{$this->lang_name}-'.\${$this->single_model_var_name}->id]
) !!} |
@endcan
@can('delete', \${$this->single_model_var_name})
@@ -67,7 +67,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.index',
trans('app.delete'),
['action' => 'delete', 'id' => \${$this->single_model_var_name}->id] + Request::only('page', 'q'),
- ['id' => 'del-{$this->single_model_var_name}-' . \${$this->single_model_var_name}->id]
+ ['id' => 'del-{$this->lang_name}-'.\${$this->single_model_var_name}->id]
) !!}
@endcan
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php
index acc6ca4..c0a538b 100644
--- a/tests/Generators/ViewsGeneratorTest.php
+++ b/tests/Generators/ViewsGeneratorTest.php
@@ -51,7 +51,7 @@ class ViewsGeneratorTest extends TestCase
@foreach(\${$this->collection_model_var_name} as \$key => \${$this->single_model_var_name})
| {{ \${$this->collection_model_var_name}->firstItem() + \$key }} |
- {{ \${$this->single_model_var_name}->name }} |
+ {{ \${$this->single_model_var_name}->nameLink() }} |
{{ \${$this->single_model_var_name}->description }} |
@can('view', \${$this->single_model_var_name})
@@ -59,7 +59,7 @@ class ViewsGeneratorTest extends TestCase
'{$this->table_name}.show',
trans('app.show'),
[\${$this->single_model_var_name}],
- ['class' => 'btn btn-default', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id]
+ ['class' => 'btn btn-default btn-xs', 'id' => 'show-{$this->lang_name}-' . \${$this->single_model_var_name}->id]
) !!}
@endcan
|
@@ -105,7 +105,8 @@ class ViewsGeneratorTest extends TestCase
@@ -161,8 +162,38 @@ class ViewsGeneratorTest extends TestCase
@section('title', trans('{$this->lang_name}.edit'))
@section('content')
+
+ @if (request('action') == 'delete' && \${$this->single_model_var_name})
+ @can('delete', \${$this->single_model_var_name})
+
+
{{ trans('{$this->lang_name}.delete') }}
+
+
+
{{ \${$this->single_model_var_name}->name }}
+
+
{{ \${$this->single_model_var_name}->description }}
+ {!! \$errors->first('{$this->lang_name}_id', '
:message') !!}
+
+
+
{{ trans('app.delete_confirm') }}
+
+
+ @endcan
+ @else
{{ trans('{$this->lang_name}.edit') }}
{!! Form::model(\${$this->single_model_var_name}, ['route' => ['{$this->table_name}.update', \${$this->single_model_var_name}->id],'method' => 'patch']) !!}
@@ -173,11 +204,13 @@ class ViewsGeneratorTest extends TestCase
{!! Form::close() !!}
+@endif
@endsection
";
$this->assertEquals($editFormViewContent, file_get_contents($editFormViewPath));