From 0b3f511534b73d366b0f2c32b95fa2f8321b148b Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 7 Apr 2020 17:26:56 -0700 Subject: [PATCH] Fixed compact() errors --- .../Controllers/AccessoriesController.php | 2 +- .../Controllers/AssetModelsController.php | 5 +---- app/Http/Controllers/CategoriesController.php | 5 +---- app/Http/Controllers/ComponentsController.php | 6 ++--- .../Controllers/DepartmentsController.php | 2 +- app/Http/Controllers/LicensesController.php | 11 +++++----- app/Http/Controllers/LocationsController.php | 2 +- .../Controllers/StatuslabelsController.php | 2 +- app/Http/Controllers/SuppliersController.php | 5 +---- app/Http/Controllers/UsersController.php | 22 +++++++++---------- 10 files changed, 24 insertions(+), 38 deletions(-) diff --git a/app/Http/Controllers/AccessoriesController.php b/app/Http/Controllers/AccessoriesController.php index 36e8a99212..d70de63630 100755 --- a/app/Http/Controllers/AccessoriesController.php +++ b/app/Http/Controllers/AccessoriesController.php @@ -198,7 +198,7 @@ class AccessoriesController extends Controller if (isset($accessory->id)) { return view('accessories/view', compact('accessory')); } - return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist', compact('id'))); + return redirect()->route('accessories.index')->with('error', trans('admin/accessories/message.does_not_exist')); } /** diff --git a/app/Http/Controllers/AssetModelsController.php b/app/Http/Controllers/AssetModelsController.php index 7c3531e475..536a951660 100755 --- a/app/Http/Controllers/AssetModelsController.php +++ b/app/Http/Controllers/AssetModelsController.php @@ -259,11 +259,8 @@ class AssetModelsController extends Controller if (isset($model->id)) { return view('models/view', compact('model')); } - // Prepare the error message - $error = trans('admin/models/message.does_not_exist', compact('id')); - // Redirect to the user management page - return redirect()->route('models.index')->with('error', $error); + return redirect()->route('models.index')->with('error', trans('admin/models/message.does_not_exist')); } /** diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php index f57ec2b4c2..a2f33ebb0a 100755 --- a/app/Http/Controllers/CategoriesController.php +++ b/app/Http/Controllers/CategoriesController.php @@ -219,10 +219,7 @@ class CategoriesController extends Controller ->with('category_type_route',$category_type_route); } - // Prepare the error message - $error = trans('admin/categories/message.does_not_exist', compact('id')); - // Redirect to the user management page - return redirect()->route('categories.index')->with('error', $error); + return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist')); } diff --git a/app/Http/Controllers/ComponentsController.php b/app/Http/Controllers/ComponentsController.php index f4106b420d..4bd7ec97c3 100644 --- a/app/Http/Controllers/ComponentsController.php +++ b/app/Http/Controllers/ComponentsController.php @@ -199,10 +199,8 @@ class ComponentsController extends Controller $this->authorize('view', $component); return view('components/view', compact('component')); } - // Prepare the error message - $error = trans('admin/components/message.does_not_exist', compact('id')); - // Redirect to the user management page - return redirect()->route('components.index')->with('error', $error); + + return redirect()->route('components.index')->with('error', trans('admin/components/message.does_not_exist')); } /** diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php index 965c98b4fa..c0788ee65a 100644 --- a/app/Http/Controllers/DepartmentsController.php +++ b/app/Http/Controllers/DepartmentsController.php @@ -79,7 +79,7 @@ class DepartmentsController extends Controller if (isset($department->id)) { return view('departments/view', compact('department')); } - return redirect()->route('departments.index')->with('error', trans('admin/departments/message.does_not_exist', compact('id'))); + return redirect()->route('departments.index')->with('error', trans('admin/departments/message.does_not_exist')); } diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index 5caacbdd26..5bae86fc77 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -455,7 +455,7 @@ class LicensesController extends Controller $this->authorize('view', $license); return view('licenses/view', compact('license')); } - return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id'))); + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); } @@ -524,9 +524,8 @@ class LicensesController extends Controller } return redirect()->route('licenses.show', $license->id)->with('error', trans('admin/licenses/message.upload.nofiles')); } - // Prepare the error message - $error = trans('admin/licenses/message.does_not_exist', compact('id')); - return redirect()->route('licenses.index')->with('error', $error); + + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); } @@ -562,7 +561,7 @@ class LicensesController extends Controller } // Redirect to the licence management page - return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id'))); + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); } @@ -613,7 +612,7 @@ class LicensesController extends Controller } - return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist', compact('id'))); + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.does_not_exist')); } diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php index d31b8a13bf..c5c5e8d3a0 100755 --- a/app/Http/Controllers/LocationsController.php +++ b/app/Http/Controllers/LocationsController.php @@ -213,7 +213,7 @@ class LocationsController extends Controller return view('locations/view', compact('location')); } - return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist', compact('id'))); + return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist')); } } diff --git a/app/Http/Controllers/StatuslabelsController.php b/app/Http/Controllers/StatuslabelsController.php index b1b743e772..7cc48f08fe 100755 --- a/app/Http/Controllers/StatuslabelsController.php +++ b/app/Http/Controllers/StatuslabelsController.php @@ -43,7 +43,7 @@ class StatuslabelsController extends Controller return view('statuslabels.view')->with('statuslabel', $statuslabel); } - return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist', compact('id'))); + return redirect()->route('statuslabels.index')->with('error', trans('admin/statuslabels/message.does_not_exist')); } diff --git a/app/Http/Controllers/SuppliersController.php b/app/Http/Controllers/SuppliersController.php index bc7934abc2..e5798353c0 100755 --- a/app/Http/Controllers/SuppliersController.php +++ b/app/Http/Controllers/SuppliersController.php @@ -195,11 +195,8 @@ class SuppliersController extends Controller if (isset($supplier->id)) { return view('suppliers/view', compact('supplier')); } - // Prepare the error message - $error = trans('admin/suppliers/message.does_not_exist', compact('id')); - // Redirect to the user management page - return redirect()->route('suppliers.index')->with('error', $error); + return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.does_not_exist')); } } diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index f1c2ebda55..ebd68b0ec1 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -606,10 +606,12 @@ class UsersController extends Controller */ public function show($userId = null) { - if(!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId)) { - $error = trans('admin/users/message.user_not_found', compact('id')); - // Redirect to the user management page - return redirect()->route('users.index')->with('error', $error); + if (!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc') + ->withTrashed() + ->find($userId)) + { + + return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found', ['id' => $userId])); } $userlog = $user->userlog->load('item'); @@ -706,10 +708,8 @@ class UsersController extends Controller ->with('userGroups', $userGroups) ->with('clone_user', $user_to_clone); } catch (UserNotFoundException $e) { - // Prepare the error message - $error = trans('admin/users/message.user_not_found', compact('id')); - // Redirect to the user management page - return redirect()->route('users.index')->with('error', $error); + + return redirect()->route('users.index')->with('error', trans('admin/users/message.user_not_found')); } } @@ -790,10 +790,8 @@ class UsersController extends Controller $log->delete(); return redirect()->back()->with('success', trans('admin/users/message.deletefile.success')); } - // Prepare the error message - $error = trans('admin/users/message.does_not_exist', compact('id')); - // Redirect to the licence management page - return redirect()->route('users.index')->with('error', $error); + + return redirect()->route('users.index')->with('error', trans('admin/users/message.does_not_exist')); }