Skip to content

A free open source IT asset/license management system

Fix more old routes. Should fix #4216 (#4217)

Daniel Meltzer22e9246031e5
diff --git a/app/Http/Controllers/CategoriesController.php b/app/Http/Controllers/CategoriesController.php
index 99504d3c69..b502050e6a 100755
--- a/app/Http/Controllers/CategoriesController.php
+++ b/app/Http/Controllers/CategoriesController.php
@@ -98,10 +98,8 @@ class CategoriesController extends Controller
*/
public function edit($categoryId = null)
{
- // Check if the category exists
if (is_null($item = Category::find($categoryId))) {
- // Redirect to the blogs management page
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.does_not_exist'));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.does_not_exist'));
}
$category_types= Helper::categoryTypeList();
@@ -158,22 +156,22 @@ class CategoriesController extends Controller
{
// Check if the category exists
if (is_null($category = Category::find($categoryId))) {
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.not_found'));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.not_found'));
}
if ($category->has_models() > 0) {
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'model']));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'model']));
} elseif ($category->accessories()->count() > 0) {
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'accessory']));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'accessory']));
} elseif ($category->consumables()->count() > 0) {
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'consumable']));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'consumable']));
} elseif ($category->components()->count() > 0) {
- return redirect()->to('admin/settings/categories')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'component']));
+ return redirect()->route('categories.index')->with('error', trans('admin/categories/message.assoc_items', ['asset_type'=>'component']));
}
$category->delete();
// Redirect to the locations management page
- return redirect()->to(route('categories.index'))->with('success', trans('admin/categories/message.delete.success'));
+ return redirect()->route('categories.index')->with('success', trans('admin/categories/message.delete.success'));
}
diff --git a/app/Http/Controllers/DepartmentsController.php b/app/Http/Controllers/DepartmentsController.php
index d5050e8286..a78e2cecf0 100644
--- a/app/Http/Controllers/DepartmentsController.php
+++ b/app/Http/Controllers/DepartmentsController.php
@@ -27,13 +27,11 @@ class DepartmentsController extends Controller
public function index(Request $request)
{
$this->authorize('index', Department::class);
+ $company = null;
if ($request->has('company_id')) {
$company = Company::find($request->input('company_id'));
- } else {
- $company = null;
}
- return view('departments/index')->with('company',$company);
-
+ return view('departments/index')->with('company', $company);
}
@@ -53,12 +51,10 @@ class DepartmentsController extends Controller
$department->user_id = Auth::user()->id;
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
-
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.create.success'));
}
return redirect()->back()->withInput()->withErrors($department->getErrors());
-
}
/**
@@ -140,25 +136,20 @@ class DepartmentsController extends Controller
->with('location_list', Helper::locationsList())
->with('company_list', Helper::companyList());
}
-
-
+
public function update(Request $request, $id) {
$this->authorize('create', Department::class);
if (is_null($department = Department::find($id))) {
- return redirect()->to('admin/settings/departments')->with('error', trans('admin/departments/message.does_not_exist'));
+ return redirect()->route('departments.index')->with('error', trans('admin/departments/message.does_not_exist'));
}
-
$department->fill($request->all());
$department->manager_id = ($request->has('manager_id' ) ? $request->input('manager_id') : null);
if ($department->save()) {
return redirect()->route("departments.index")->with('success', trans('admin/departments/message.update.success'));
}
-
return redirect()->back()->withInput()->withErrors($department->getErrors());
}
-
-
}
diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php
index 4abdfa65e1..ffe480c63f 100755
--- a/app/Http/Controllers/LocationsController.php
+++ b/app/Http/Controllers/LocationsController.php
@@ -148,7 +148,7 @@ class LocationsController extends Controller
{
// Check if the location exists
if (is_null($item = Location::find($locationId))) {
- return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.does_not_exist'));
+ return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
}
// Show the page
@@ -157,7 +157,6 @@ class LocationsController extends Controller
$location_options = Location::flattenLocationsArray($location_options_array);
$location_options = array('' => 'Top Level') + $location_options;
-
return view('locations/edit', compact('item'))
->with('location_options', $location_options)
->with('manager_list', Helper::managerList());
@@ -177,7 +176,7 @@ class LocationsController extends Controller
{
// Check if the location exists
if (is_null($location = Location::find($locationId))) {
- return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.does_not_exist'));
+ return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
}
// Update the location data
@@ -218,7 +217,6 @@ class LocationsController extends Controller
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found'));
}
-
if ($location->users->count() > 0) {
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
} elseif ($location->childLocations->count() > 0) {