From 64a510490644d5f42424bd029ceeacd8e8bf90ad Mon Sep 17 00:00:00 2001 From: Jonathan Reinink Date: Wed, 18 Dec 2019 17:34:14 -0500 Subject: [PATCH] Simplify redirects --- app/Http/Controllers/ContactsController.php | 6 +++--- app/Http/Controllers/OrganizationsController.php | 6 +++--- app/Http/Controllers/UsersController.php | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/ContactsController.php b/app/Http/Controllers/ContactsController.php index 88f8653..3b2d462 100644 --- a/app/Http/Controllers/ContactsController.php +++ b/app/Http/Controllers/ContactsController.php @@ -111,20 +111,20 @@ class ContactsController extends Controller ]) ); - return Redirect::route('contacts.edit', $contact)->with('success', 'Contact updated.'); + return Redirect::back()->with('success', 'Contact updated.'); } public function destroy(Contact $contact) { $contact->delete(); - return Redirect::route('contacts.edit', $contact)->with('success', 'Contact deleted.'); + return Redirect::back()->with('success', 'Contact deleted.'); } public function restore(Contact $contact) { $contact->restore(); - return Redirect::route('contacts.edit', $contact)->with('success', 'Contact restored.'); + return Redirect::back()->with('success', 'Contact restored.'); } } diff --git a/app/Http/Controllers/OrganizationsController.php b/app/Http/Controllers/OrganizationsController.php index 06ce57a..7db6f65 100644 --- a/app/Http/Controllers/OrganizationsController.php +++ b/app/Http/Controllers/OrganizationsController.php @@ -79,20 +79,20 @@ class OrganizationsController extends Controller ]) ); - return Redirect::route('organizations.edit', $organization)->with('success', 'Organization updated.'); + return Redirect::back()->with('success', 'Organization updated.'); } public function destroy(Organization $organization) { $organization->delete(); - return Redirect::route('organizations.edit', $organization)->with('success', 'Organization deleted.'); + return Redirect::back()->with('success', 'Organization deleted.'); } public function restore(Organization $organization) { $organization->restore(); - return Redirect::route('organizations.edit', $organization)->with('success', 'Organization restored.'); + return Redirect::back()->with('success', 'Organization restored.'); } } diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index bcb1d3b..1e83760 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -79,8 +79,8 @@ class UsersController extends Controller public function update(User $user) { - return Redirect::route('users.edit', $user)->with('error', 'Updating the demo user is not allowed.'); if (App::environment('demo') && $user->isDemoUser()) { + return Redirect::back()->with('error', 'Updating the demo user is not allowed.'); } Request::validate([ @@ -102,24 +102,24 @@ class UsersController extends Controller $user->update(['password' => Request::get('password')]); } - return Redirect::route('users.edit', $user)->with('success', 'User updated.'); + return Redirect::back()->with('success', 'User updated.'); } public function destroy(User $user) { - return Redirect::route('users.edit', $user)->with('error', 'Deleting the demo user is not allowed.'); if (App::environment('demo') && $user->isDemoUser()) { + return Redirect::back()->with('error', 'Deleting the demo user is not allowed.'); } $user->delete(); - return Redirect::route('users.edit', $user)->with('success', 'User deleted.'); + return Redirect::back()->with('success', 'User deleted.'); } public function restore(User $user) { $user->restore(); - return Redirect::route('users.edit', $user)->with('success', 'User restored.'); + return Redirect::back()->with('success', 'User restored.'); } }