From 23d701bb311536aa7f98e9063708a9b4bedd381e Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Sun, 4 Mar 2018 18:32:57 +0800 Subject: [PATCH] Remove variabel that cause invalid redirection Model variable in update method on controller.full.stub will always return 1, so it will cause invalid redirection on every model update action Remove unused variable on controller update method --- src/stubs/controller.full.stub | 2 +- src/stubs/controller.simple.stub | 2 +- tests/Generators/FullControllerGeneratorTest.php | 6 +++--- tests/Generators/Simple/SimpleControllerGeneratorTest.php | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stubs/controller.full.stub b/src/stubs/controller.full.stub index 27d2436..dc5ea0f 100644 --- a/src/stubs/controller.full.stub +++ b/src/stubs/controller.full.stub @@ -96,7 +96,7 @@ class MastersController extends Controller 'description' => 'nullable|max:255', ]); - $singleMstr = $singleMstr->update($request->only('name', 'description')); + $singleMstr->update($request->only('name', 'description')); return redirect()->route('masters.show', $singleMstr); } diff --git a/src/stubs/controller.simple.stub b/src/stubs/controller.simple.stub index b593d1a..2e7a58a 100644 --- a/src/stubs/controller.simple.stub +++ b/src/stubs/controller.simple.stub @@ -67,7 +67,7 @@ class MastersController extends Controller $routeParam = request()->only('page', 'q'); - $singleMstr = $singleMstr->update($request->only('name', 'description')); + $singleMstr->update($request->only('name', 'description')); return redirect()->route('masters.index', $routeParam); } diff --git a/tests/Generators/FullControllerGeneratorTest.php b/tests/Generators/FullControllerGeneratorTest.php index 863c0ca..33f2db2 100644 --- a/tests/Generators/FullControllerGeneratorTest.php +++ b/tests/Generators/FullControllerGeneratorTest.php @@ -110,7 +110,7 @@ class {$this->plural_model_name}Controller extends Controller 'description' => 'nullable|max:255', ]); - \${$this->single_model_var_name} = \${$this->single_model_var_name}->update(\$request->only('name', 'description')); + \${$this->single_model_var_name}->update(\$request->only('name', 'description')); return redirect()->route('{$this->table_name}.show', \${$this->single_model_var_name}); } @@ -246,7 +246,7 @@ class CategoriesController extends Controller 'description' => 'nullable|max:255', ]); - \$category = \$category->update(\$request->only('name', 'description')); + \$category->update(\$request->only('name', 'description')); return redirect()->route('categories.show', \$category); } @@ -383,7 +383,7 @@ class CategoriesController extends Controller 'description' => 'nullable|max:255', ]); - \$category = \$category->update(\$request->only('name', 'description')); + \$category->update(\$request->only('name', 'description')); return redirect()->route('categories.show', \$category); } diff --git a/tests/Generators/Simple/SimpleControllerGeneratorTest.php b/tests/Generators/Simple/SimpleControllerGeneratorTest.php index 6da64ae..bc831ad 100644 --- a/tests/Generators/Simple/SimpleControllerGeneratorTest.php +++ b/tests/Generators/Simple/SimpleControllerGeneratorTest.php @@ -81,7 +81,7 @@ class {$this->plural_model_name}Controller extends Controller \$routeParam = request()->only('page', 'q'); - \${$this->single_model_var_name} = \${$this->single_model_var_name}->update(\$request->only('name', 'description')); + \${$this->single_model_var_name}->update(\$request->only('name', 'description')); return redirect()->route('{$this->table_name}.index', \$routeParam); } @@ -188,7 +188,7 @@ class CategoriesController extends Controller \$routeParam = request()->only('page', 'q'); - \$category = \$category->update(\$request->only('name', 'description')); + \$category->update(\$request->only('name', 'description')); return redirect()->route('categories.index', \$routeParam); } @@ -296,7 +296,7 @@ class CategoriesController extends Controller \$routeParam = request()->only('page', 'q'); - \$category = \$category->update(\$request->only('name', 'description')); + \$category->update(\$request->only('name', 'description')); return redirect()->route('categories.index', \$routeParam); }