2015-10-31 77 views
4

重定向我尝试laravel和删除注销

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\[email protected]']); 

如何获得向下的自动在那种情况下从url http://localhost/myproj/public/log_out重定向? 谢谢

回答

3

你是什么意思?自动?你想注销用户,然后重定向,对吧?您可以同时重定向并刷新消息,这在这种情况下很有意义。

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

更多here