A free open source IT asset/license management system
editing controllers and edit blades for other categories
Godfrey M8a9cf07063d5
diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.phpindex 846b44fdc3..2d1968a5aa 100644--- a/app/Helpers/Helper.php+++ b/app/Helpers/Helper.php@@ -1484,7 +1484,7 @@ class Helperstatic public function getRedirectOption($request, $id, $table, $item_id = null) : RedirectResponse{- $redirect_option = Session::get('redirect_option');+ $redirect_option = Session::get('redirect_option') ?? $request->input('redirect_option');$checkout_to_type = Session::get('checkout_to_type');$checkedInFrom = Session::get('checkedInFrom');$other_redirect = Session::get('other_redirect');diff --git a/app/Http/Controllers/Components/ComponentsController.php b/app/Http/Controllers/Components/ComponentsController.phpindex 74594d312b..0a4a327167 100644--- a/app/Http/Controllers/Components/ComponentsController.php+++ b/app/Http/Controllers/Components/ComponentsController.php@@ -91,7 +91,8 @@ class ComponentsController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($component->save()) {- return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.create.success'));+ return Helper::getRedirectOption($request, $component->id, 'Components')+ ->with('success', trans('admin/components/message.create.success'));}return redirect()->back()->withInput()->withErrors($component->getErrors());@@ -111,6 +112,7 @@ class ComponentsController extends Controller{$this->authorize('update', $component);+ session()->put('back_url', url()->previous());return view('components/edit')->with('item', $component)->with('category_type', 'component');@@ -164,7 +166,8 @@ class ComponentsController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($component->save()) {- return redirect()->to(Helper::getRedirectOption($request, $component->id, 'Components'))->with('success', trans('admin/components/message.update.success'));+ return Helper::getRedirectOption($request, $component->id, 'Components')+ ->with('success', trans('admin/components/message.update.success'));}return redirect()->back()->withInput()->withErrors($component->getErrors());diff --git a/app/Http/Controllers/Consumables/ConsumablesController.php b/app/Http/Controllers/Consumables/ConsumablesController.phpindex c96c2db975..dc0b7e4b3d 100644--- a/app/Http/Controllers/Consumables/ConsumablesController.php+++ b/app/Http/Controllers/Consumables/ConsumablesController.php@@ -90,7 +90,8 @@ class ConsumablesController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($consumable->save()) {- return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.create.success'));+ return Helper::getRedirectOption($request, $consumable->id, 'Consumables')+ ->with('success', trans('admin/consumables/message.create.success'));}return redirect()->back()->withInput()->withErrors($consumable->getErrors());@@ -107,6 +108,7 @@ class ConsumablesController extends Controllerpublic function edit(Consumable $consumable) : View | RedirectResponse{$this->authorize($consumable);+ session()->put('back_url', url()->previous());return view('consumables/edit')->with('item', $consumable)->with('category_type', 'consumable');@@ -160,7 +162,8 @@ class ConsumablesController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($consumable->save()) {- return redirect()->to(Helper::getRedirectOption($request, $consumable->id, 'Consumables'))->with('success', trans('admin/consumables/message.update.success'));+ return Helper::getRedirectOption($request, $consumable->id, 'Consumables')+ ->with('success', trans('admin/consumables/message.update.success'));}return redirect()->back()->withInput()->withErrors($consumable->getErrors());diff --git a/app/Http/Controllers/Licenses/LicensesController.php b/app/Http/Controllers/Licenses/LicensesController.phpindex ab1e3868d2..458b1ce15b 100755--- a/app/Http/Controllers/Licenses/LicensesController.php+++ b/app/Http/Controllers/Licenses/LicensesController.php@@ -105,7 +105,8 @@ class LicensesController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($license->save()) {- return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.create.success'));+ return Helper::getRedirectOption($request, $license->id, 'Licenses')+ ->with('success', trans('admin/licenses/message.create.success'));}return redirect()->back()->withInput()->withErrors($license->getErrors());@@ -125,7 +126,7 @@ class LicensesController extends Controller{$this->authorize('update', $license);-+ session()->put('back_url', url()->previous());$maintained_list = ['' => 'Maintained','1' => 'Yes',@@ -181,7 +182,8 @@ class LicensesController extends Controllersession()->put(['redirect_option' => $request->get('redirect_option')]);if ($license->save()) {- return redirect()->to(Helper::getRedirectOption($request, $license->id, 'Licenses'))->with('success', trans('admin/licenses/message.update.success'));+ return Helper::getRedirectOption($request, $license->id, 'Licenses')+ ->with('success', trans('admin/licenses/message.update.success'));}// If we can't adjust the number of seats, the error is flashed to the session by the event handler in License.phpreturn redirect()->back()->withInput()->withErrors($license->getErrors());diff --git a/app/Http/Controllers/Users/UsersController.php b/app/Http/Controllers/Users/UsersController.phpindex b18a7b6fff..2e4ec50e93 100755--- a/app/Http/Controllers/Users/UsersController.php+++ b/app/Http/Controllers/Users/UsersController.php@@ -154,7 +154,8 @@ class UsersController extends Controller$user->notify(new WelcomeNotification($data));}- return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))->with('success', trans('admin/users/message.success.create'));+ return Helper::getRedirectOption($request, $user->id, 'Users')+ ->with('success', trans('admin/users/message.success.create'));}return redirect()->back()->withInput()->withErrors($user->getErrors());@@ -186,6 +187,7 @@ class UsersController extends Controller{$this->authorize('update', User::class);+ session()->put('back_url', url()->previous());$user = User::with(['assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc'])->withTrashed()->find($user->id);if ($user) {@@ -312,7 +314,7 @@ class UsersController extends Controllerif ($user->save()) {// Redirect to the user page- return redirect()->to(Helper::getRedirectOption($request, $user->id, 'Users'))+ return Helper::getRedirectOption($request, $user->id, 'Users')->with('success', trans('admin/users/message.success.update'));}return redirect()->back()->withInput()->withErrors($user->getErrors());diff --git a/resources/views/components/edit.blade.php b/resources/views/components/edit.blade.phpindex 979d68248c..b9a393f1d1 100644--- a/resources/views/components/edit.blade.php+++ b/resources/views/components/edit.blade.php@@ -6,6 +6,7 @@'formAction' => (isset($item->id)) ? route('components.update', ['component' => $item->id]) : route('components.store'),'index_route' => 'components.index','options' => [+ 'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'components']),'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.component')]),]diff --git a/resources/views/consumables/edit.blade.php b/resources/views/consumables/edit.blade.phpindex e844338fa7..5b8dd736c6 100644--- a/resources/views/consumables/edit.blade.php+++ b/resources/views/consumables/edit.blade.php@@ -6,6 +6,7 @@'formAction' => (isset($item->id)) ? route('consumables.update', ['consumable' => $item->id]) : route('consumables.store'),'index_route' => 'consumables.index','options' => [+ 'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'consumables']),'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.consumable')]),]diff --git a/resources/views/licenses/edit.blade.php b/resources/views/licenses/edit.blade.phpindex 7bb12728bc..87b0180216 100755--- a/resources/views/licenses/edit.blade.php+++ b/resources/views/licenses/edit.blade.php@@ -5,6 +5,7 @@'formAction' => ($item->id) ? route('licenses.update', ['license' => $item->id]) : route('licenses.store'),'index_route' => 'licenses.index','options' => [+ 'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'licenses']),'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.license')]),]diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.phpindex 78344f5b3f..4e2293f59b 100755--- a/resources/views/users/edit.blade.php+++ b/resources/views/users/edit.blade.php@@ -599,6 +599,7 @@index_route="users.index":button_label="trans('general.save')":options="[+ 'back' => trans('admin/hardware/form.redirect_to_type',['type' => trans('general.previous_page')]),'index' => trans('admin/hardware/form.redirect_to_all', ['type' => 'users']),'item' => trans('admin/hardware/form.redirect_to_type', ['type' => trans('general.user')]),]"