我尝试在登录后将Laravel
页面重定向到另一个家庭,但每次都会将我重定向到home
。我所做的是:我将protected $redirectTo =
的值从home
更改为protected $redirectTo = 'S1CheckUserTables';
。
我还在web.php
中定义了我的路线如下(我觉得我将使用命名路线):
Route::get('/S1CheckUserTables', ['as'=>'S1CheckUserTables', 'uses'=>'S1CheckUserTablesController@index']);
我也尝试使用以下语法来解决问题,但它也不起作用:
Route::get('S1CheckUserTables', 'S1CheckUserTablesController@index')->name('S1CheckUserTables');
请您告诉我什么可以解决我的问题?非常感谢你提前。
答案 0 :(得分:3)
登录后的laravel默认重定向是转到LoginController中的/ home设置:
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
并且有默认的中间件RedirectIfAuthenticated
class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
}
return $next($request);
}
}
并在app / Http / Controllers / Auth / RegisterController.php
中class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after login / registration.
*
* @var string
*/
protected $redirectTo = '/home';
这就是你需要做出改变以便按照自己的方式工作的地方......