Skip to content

Commit

Permalink
[11.x] Add symmetrical convenience method (laravel#50408)
Browse files Browse the repository at this point in the history
* Add symmetrical convenience method

Since a `redirectGuestsTo` convenience method exists, I felt a `redirectUsersTo` convenience method should also exist. Especially since `users` is the second optional argument, as this would avoid using named parameters when it's the only redirect a user sets.

* Update Middleware.php

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
jasonmccreary and taylorotwell committed Mar 7, 2024
1 parent 0289046 commit f7f8784
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Illuminate/Foundation/Configuration/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public function getMiddlewareGroups()
}

/**
* Configure where guests are redirected by the authentication middleware.
* Configure where guests are redirected by the "auth" middleware.
*
* @param callable|string $redirect
* @return $this
Expand All @@ -500,6 +500,17 @@ public function redirectGuestsTo(callable|string $redirect)
return $this->redirectTo(guests: $redirect);
}

/**
* Configure where users are redirected by the "guest" middleware.
*
* @param callable|string $redirect
* @return $this
*/
public function redirectUsersTo(callable|string $redirect)
{
return $this->redirectTo(users: $redirect);
}

/**
* Configure where users are redirected by the authentication and guest middleware.
*
Expand Down

0 comments on commit f7f8784

Please sign in to comment.