problem description
assuming that the user is required to log in before publishing new information, determine whether the user is logged in or not and redirect the page by registering the middleware in the controller layer.
the environmental background of the problems and what methods you have tried
I intend to redefine the page by modifying the url within the request object, but this does not convey a prompt or redirect the page.
related codes
public function handle($request, \Closure $next)
{
dump(session("userInfo"));
if (session("?userInfo")) {
return $next($request);
} else {
$request->url = "/tp5/public/?s=/user/signIn";
return $next($request);
}
}