Php Laravel 5.6:登记表后重定向
我有一个laravel项目,需要我在注册后重定向到登录,而不是登录到主屏幕。我曾尝试在RegisterController中使用$redirectTo,但它似乎被忽略,控制权被移交到主页。我怎样才能纠正这一点Php Laravel 5.6:登记表后重定向,php,laravel,Php,Laravel,我有一个laravel项目,需要我在注册后重定向到登录,而不是登录到主屏幕。我曾尝试在RegisterController中使用$redirectTo,但它似乎被忽略,控制权被移交到主页。我怎样才能纠正这一点 protected $redirectTo = '/login'; /** * Create a new controller instance. * * @return void */ public function __construct() { $this->
protected $redirectTo = '/login';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
默认情况下,Laravel在注册后生成会话,因此您需要将下面给定的代码放入RegisterController中
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
return redirect($this->redirectPath())->with('message', 'Your message');
}
谢谢你@Rahul