在raravel 5.2中,Redirect :: back()不起作用

Gir*_*Lal 0 php redirect laravel

if(count($data) == 1){
            return view('welcome');
        }
        else {
            // echo "dslkfjads";
            Redirect::back()->with('message','Username or password not Match!'); 
        }
Run Code Online (Sandbox Code Playgroud)

上面的Redirect :: back()函数在登录时不起作用.如果我正在打印它正在显示的任何内容

Moe*_*mel 7

您必须返回响应对象,因此您的代码应如下所示:

if (count($data) == 1) {
    return view('welcome');
} else {
    return Redirect::back()->with('message', 'Username or password not Match!');
}
Run Code Online (Sandbox Code Playgroud)