diff --git a/src/stubs/controllers/api.stub b/src/stubs/controllers/api.stub index bac89cb..7fce7b5 100644 --- a/src/stubs/controllers/api.stub +++ b/src/stubs/controllers/api.stub @@ -13,10 +13,11 @@ class MasterController extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function index() + public function index(Request $request) { $singleMstrQuery = Master::query(); - $singleMstrQuery->where('title', 'like', '%'.request('q').'%'); + $singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%'); + $singleMstrQuery->orderBy('title'); $mstrCollections = $singleMstrQuery->paginate(25); return $mstrCollections; diff --git a/src/stubs/controllers/full-formrequests.stub b/src/stubs/controllers/full-formrequests.stub index 1d0e38f..2efb58e 100644 --- a/src/stubs/controllers/full-formrequests.stub +++ b/src/stubs/controllers/full-formrequests.stub @@ -14,10 +14,11 @@ class MasterController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request $request) { $singleMstrQuery = Master::query(); - $singleMstrQuery->where('title', 'like', '%'.request('q').'%'); + $singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%'); + $singleMstrQuery->orderBy('title'); $mstrCollections = $singleMstrQuery->paginate(25); return view('masters.index', compact('mstrCollections')); diff --git a/src/stubs/controllers/full.stub b/src/stubs/controllers/full.stub index 7a4a455..c108603 100644 --- a/src/stubs/controllers/full.stub +++ b/src/stubs/controllers/full.stub @@ -12,10 +12,11 @@ class MasterController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request $request) { $singleMstrQuery = Master::query(); - $singleMstrQuery->where('title', 'like', '%'.request('q').'%'); + $singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%'); + $singleMstrQuery->orderBy('title'); $mstrCollections = $singleMstrQuery->paginate(25); return view('masters.index', compact('mstrCollections')); diff --git a/src/stubs/controllers/simple.stub b/src/stubs/controllers/simple.stub index c1c1564..f5ff38d 100644 --- a/src/stubs/controllers/simple.stub +++ b/src/stubs/controllers/simple.stub @@ -12,11 +12,12 @@ class MasterController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request $request) { $editableMaster = null; $singleMstrQuery = Master::query(); - $singleMstrQuery->where('title', 'like', '%'.request('q').'%'); + $singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%'); + $singleMstrQuery->orderBy('title'); $mstrCollections = $singleMstrQuery->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { diff --git a/tests/CommandOptions/FullCrudFormRequestOptionsTest.php b/tests/CommandOptions/FullCrudFormRequestOptionsTest.php index 9d382d0..874f6b3 100644 --- a/tests/CommandOptions/FullCrudFormRequestOptionsTest.php +++ b/tests/CommandOptions/FullCrudFormRequestOptionsTest.php @@ -59,10 +59,11 @@ class {$this->model_name}Controller extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%'); + \${$this->single_model_var_name}Query->orderBy('title'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}')); diff --git a/tests/Generators/Api/ApiControllerGeneratorTest.php b/tests/Generators/Api/ApiControllerGeneratorTest.php index 1a27ea6..432c4a9 100644 --- a/tests/Generators/Api/ApiControllerGeneratorTest.php +++ b/tests/Generators/Api/ApiControllerGeneratorTest.php @@ -27,10 +27,11 @@ class {$this->model_name}Controller extends Controller * * @return \Illuminate\Http\JsonResponse */ - public function index() + public function index(Request \$request) { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%'); + \${$this->single_model_var_name}Query->orderBy('title'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return \${$this->collection_model_var_name}; diff --git a/tests/Generators/FullControllerGeneratorTest.php b/tests/Generators/FullControllerGeneratorTest.php index 3fdd5b3..29974f5 100644 --- a/tests/Generators/FullControllerGeneratorTest.php +++ b/tests/Generators/FullControllerGeneratorTest.php @@ -26,10 +26,11 @@ class {$this->model_name}Controller extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%'); + \${$this->single_model_var_name}Query->orderBy('title'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); return view('{$this->table_name}.index', compact('{$this->collection_model_var_name}')); @@ -156,10 +157,11 @@ class CategoryController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \$categoryQuery = Category::query(); - \$categoryQuery->where('title', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%'); + \$categoryQuery->orderBy('title'); \$categories = \$categoryQuery->paginate(25); return view('categories.index', compact('categories')); @@ -287,10 +289,11 @@ class CategoryController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \$categoryQuery = Category::query(); - \$categoryQuery->where('title', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%'); + \$categoryQuery->orderBy('title'); \$categories = \$categoryQuery->paginate(25); return view('categories.index', compact('categories')); diff --git a/tests/Generators/Simple/SimpleControllerGeneratorTest.php b/tests/Generators/Simple/SimpleControllerGeneratorTest.php index 7379ae2..843441c 100644 --- a/tests/Generators/Simple/SimpleControllerGeneratorTest.php +++ b/tests/Generators/Simple/SimpleControllerGeneratorTest.php @@ -26,11 +26,12 @@ class {$this->model_name}Controller extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \$editable{$this->model_name} = null; \${$this->single_model_var_name}Query = {$this->model_name}::query(); - \${$this->single_model_var_name}Query->where('title', 'like', '%'.request('q').'%'); + \${$this->single_model_var_name}Query->where('title', 'like', '%'.\$request->get('q').'%'); + \${$this->single_model_var_name}Query->orderBy('title'); \${$this->collection_model_var_name} = \${$this->single_model_var_name}Query->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { @@ -129,11 +130,12 @@ class CategoryController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \$editableCategory = null; \$categoryQuery = Category::query(); - \$categoryQuery->where('title', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%'); + \$categoryQuery->orderBy('title'); \$categories = \$categoryQuery->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) { @@ -233,11 +235,12 @@ class CategoryController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request \$request) { \$editableCategory = null; \$categoryQuery = Category::query(); - \$categoryQuery->where('title', 'like', '%'.request('q').'%'); + \$categoryQuery->where('title', 'like', '%'.\$request->get('q').'%'); + \$categoryQuery->orderBy('title'); \$categories = \$categoryQuery->paginate(25); if (in_array(request('action'), ['edit', 'delete']) && request('id') != null) {