source: app/Http/Middleware/RedirectIfAuthenticated.php@ c454c0f

main
Last change on this file since c454c0f was c454c0f, checked in by bube-ristovska <ristovska725@…>, 11 months ago

First commit

  • Property mode set to 100644
File size: 760 bytes
Line 
1<?php
2
3namespace App\Http\Middleware;
4
5use App\Providers\RouteServiceProvider;
6use Closure;
7use Illuminate\Http\Request;
8use Illuminate\Support\Facades\Auth;
9use Symfony\Component\HttpFoundation\Response;
10
11class RedirectIfAuthenticated
12{
13 /**
14 * Handle an incoming request.
15 *
16 * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
17 */
18 public function handle(Request $request, Closure $next, string ...$guards): Response
19 {
20 $guards = empty($guards) ? [null] : $guards;
21
22 foreach ($guards as $guard) {
23 if (Auth::guard($guard)->check()) {
24 return redirect(RouteServiceProvider::HOME);
25 }
26 }
27
28 return $next($request);
29 }
30}
Note: See TracBrowser for help on using the repository browser.