clrghouz/app/Http/Middleware/RedirectIfAuthenticated.php

29 lines
589 B
PHP
Raw Normal View History

2018-11-15 10:45:49 +00:00
<?php
namespace App\Http\Middleware;
2023-06-27 07:39:11 +00:00
use Illuminate\Http\Request;
2018-11-15 10:45:49 +00:00
use Illuminate\Support\Facades\Auth;
2023-06-27 07:39:11 +00:00
use App\Providers\RouteServiceProvider;
2018-11-15 10:45:49 +00:00
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
2023-06-27 07:39:11 +00:00
* @param Request $request
* @param \Closure $next
* @param string|null $guard
2018-11-15 10:45:49 +00:00
* @return mixed
*/
2023-06-27 07:39:11 +00:00
public function handle(Request $request,\Closure $next,?string $guard=NULL)
2018-11-15 10:45:49 +00:00
{
if (Auth::guard($guard)->check()) {
2021-06-13 03:56:27 +00:00
return redirect(RouteServiceProvider::HOME);
2018-11-15 10:45:49 +00:00
}
return $next($request);
}
}