diff --git a/src/stubs/controller.model.stub b/src/stubs/controller.model.stub
index 401d8c2..aa55307 100644
--- a/src/stubs/controller.model.stub
+++ b/src/stubs/controller.model.stub
@@ -39,8 +39,6 @@ class MastersController extends Controller
Master::create($request->only('name', 'description'));
- flash(trans('master.created'), 'success');
-
return redirect()->route('masters.index');
}
@@ -58,11 +56,11 @@ class MastersController extends Controller
'description' => 'required|max:255',
]);
- $master = $master->update($request->only('name', 'description'));
+ $routeParam = request()->only('page', 'q');
- flash(trans('master.updated'), 'success');
+ $master = $master->update($request->only('name', 'description'));
- return redirect()->route('masters.index');
+ return redirect()->route('masters.index', $routeParam);
}
/**
@@ -77,14 +75,12 @@ class MastersController extends Controller
'master_id' => 'required',
]);
- if (request('master_id') == $master->id && $master->delete()) {
- flash(trans('master.deleted'), 'success');
+ $routeParam = request()->only('page', 'q');
- return redirect()->route('masters.index');
+ if (request('master_id') == $master->id && $master->delete()) {
+ return redirect()->route('masters.index', $routeParam);
}
- flash(trans('master.undeleted'), 'error');
-
return back();
}
}
diff --git a/src/stubs/test-feature.stub b/src/stubs/test-feature.stub
index d981708..c81f416 100644
--- a/src/stubs/test-feature.stub
+++ b/src/stubs/test-feature.stub
@@ -59,7 +59,7 @@ class ManageMastersTest extends TestCase
$this->type('Master 1 description', 'description');
$this->press(trans('master.update'));
- $this->visit(route('masters.index', ['q' => '123']));
+ $this->seePageIs(route('masters.index', ['q' => '123']));
$this->seeInDatabase('masters', [
'name' => 'Master 1 name',
diff --git a/src/stubs/view-forms.stub b/src/stubs/view-forms.stub
index 865535e..60566af 100644
--- a/src/stubs/view-forms.stub
+++ b/src/stubs/view-forms.stub
@@ -11,6 +11,12 @@
{!! Form::model($editableMaster, ['route' => ['masters.update', $editableMaster->id],'method' => 'patch']) !!}
{!! FormField::text('name') !!}
{!! FormField::textarea('description') !!}
+ @if (request('q'))
+ {{ Form::hidden('q', request('q')) }}
+ @endif
+ @if (request('page'))
+ {{ Form::hidden('page', request('page')) }}
+ @endif
{!! Form::submit(trans('master.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('masters.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! Form::close() !!}
@@ -26,7 +32,16 @@
{{ trans('app.delete_confirm') }}
diff --git a/src/stubs/view-index.stub b/src/stubs/view-index.stub
index 6148dcd..853c249 100644
--- a/src/stubs/view-index.stub
+++ b/src/stubs/view-index.stub
@@ -24,8 +24,18 @@
{{ $master->name }} |
{{ $master->description }} |
- {!! link_to_route('masters.index', trans('app.edit'), ['action' => 'edit', 'id' => $master->id], ['id' => 'edit-master-' . $master->id]) !!} |
- {!! link_to_route('masters.index', trans('app.delete'), ['action' => 'delete', 'id' => $master->id], ['id' => 'del-master-' . $master->id]) !!}
+ {!! link_to_route(
+ 'items.index',
+ trans('app.edit'),
+ ['action' => 'edit', 'id' => $item->id] + Request::only('page', 'q'),
+ ['id' => 'edit-item-' . $item->id]
+ ) !!} |
+ {!! link_to_route(
+ 'items.index',
+ trans('app.delete'),
+ ['action' => 'delete', 'id' => $item->id] + Request::only('page', 'q'),
+ ['id' => 'del-item-' . $item->id]
+ ) !!}
|
@endforeach
diff --git a/tests/Generators/ControllerGeneratorTest.php b/tests/Generators/ControllerGeneratorTest.php
index 5b280bc..dd5c1cc 100644
--- a/tests/Generators/ControllerGeneratorTest.php
+++ b/tests/Generators/ControllerGeneratorTest.php
@@ -53,8 +53,6 @@ class ItemsController extends Controller
Item::create(\$request->only('name', 'description'));
- flash(trans('item.created'), 'success');
-
return redirect()->route('items.index');
}
@@ -72,11 +70,11 @@ class ItemsController extends Controller
'description' => 'required|max:255',
]);
- \$item = \$item->update(\$request->only('name', 'description'));
+ \$routeParam = request()->only('page', 'q');
- flash(trans('item.updated'), 'success');
+ \$item = \$item->update(\$request->only('name', 'description'));
- return redirect()->route('items.index');
+ return redirect()->route('items.index', \$routeParam);
}
/**
@@ -91,14 +89,12 @@ class ItemsController extends Controller
'item_id' => 'required',
]);
- if (request('item_id') == \$item->id && \$item->delete()) {
- flash(trans('item.deleted'), 'success');
+ \$routeParam = request()->only('page', 'q');
- return redirect()->route('items.index');
+ if (request('item_id') == \$item->id && \$item->delete()) {
+ return redirect()->route('items.index', \$routeParam);
}
- flash(trans('item.undeleted'), 'error');
-
return back();
}
}
diff --git a/tests/Generators/FeatureTestGeneratorTest.php b/tests/Generators/FeatureTestGeneratorTest.php
index 180be85..360401c 100644
--- a/tests/Generators/FeatureTestGeneratorTest.php
+++ b/tests/Generators/FeatureTestGeneratorTest.php
@@ -110,7 +110,7 @@ class ManageItemsTest extends TestCase
\$this->type('Item 1 description', 'description');
\$this->press(trans('item.update'));
- \$this->visit(route('items.index', ['q' => '123']));
+ \$this->seePageIs(route('items.index', ['q' => '123']));
\$this->seeInDatabase('items', [
'name' => 'Item 1 name',
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php
index 252df0d..da7a214 100644
--- a/tests/Generators/ViewsGeneratorTest.php
+++ b/tests/Generators/ViewsGeneratorTest.php
@@ -39,8 +39,18 @@ class ViewsGeneratorTest extends TestCase
{{ \$item->name }} |
{{ \$item->description }} |
- {!! link_to_route('items.index', trans('app.edit'), ['action' => 'edit', 'id' => \$item->id], ['id' => 'edit-item-' . \$item->id]) !!} |
- {!! link_to_route('items.index', trans('app.delete'), ['action' => 'delete', 'id' => \$item->id], ['id' => 'del-item-' . \$item->id]) !!}
+ {!! link_to_route(
+ 'items.index',
+ trans('app.edit'),
+ ['action' => 'edit', 'id' => \$item->id] + Request::only('page', 'q'),
+ ['id' => 'edit-item-' . \$item->id]
+ ) !!} |
+ {!! link_to_route(
+ 'items.index',
+ trans('app.delete'),
+ ['action' => 'delete', 'id' => \$item->id] + Request::only('page', 'q'),
+ ['id' => 'del-item-' . \$item->id]
+ ) !!}
|
@endforeach
@@ -77,6 +87,12 @@ class ViewsGeneratorTest extends TestCase
{!! Form::model(\$editableItem, ['route' => ['items.update', \$editableItem->id],'method' => 'patch']) !!}
{!! FormField::text('name') !!}
{!! FormField::textarea('description') !!}
+ @if (request('q'))
+ {{ Form::hidden('q', request('q')) }}
+ @endif
+ @if (request('page'))
+ {{ Form::hidden('page', request('page')) }}
+ @endif
{!! Form::submit(trans('item.update'), ['class' => 'btn btn-success']) !!}
{{ link_to_route('items.index', trans('app.cancel'), [], ['class' => 'btn btn-default']) }}
{!! Form::close() !!}
@@ -92,7 +108,16 @@ class ViewsGeneratorTest extends TestCase
{{ trans('app.delete_confirm') }}