laravel和从注销中删除重定向


laravel and removing redirecting from a logout

我尝试添加一个函数

public function postLogout() {
    //Auth::logout();
    return response()->json(['msg' => 'You have signed out']);
}

进入文件

'vendor'laravel'framework'src'Illuminate'Foundation'Auth'AuthenticatesUsers.php

并使用路线

Route::get('log_out', ['as' => 'auth.log_out', 'uses' => 'Auth'AuthController@postLogout']);

如何从url自动重定向http://localhost/myproj/public/log_out在这种情况下???感谢

"自动"是什么意思?你想注销用户,然后重定向,对吗?您可以同时重定向和闪烁消息,这在这种情况下是有意义的。

Route::get('log_out', function () {
   //Auth::logout();
   return redirect('log_in')->with('status', 'You have signed out!');
});

点击此处阅读更多