I have the following route:

Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout'); 

he redirects them through the function

 public function __construct() { $this->middleware('guest')->except('logout'); } 

How can I redirect the route to another page? Tried to use regular query view.

 Route::redirect('/logout', '/auth/login', 301); 

or even so

 Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout', function(){ return view('auth.login'); }); 

but unfortunately something is not working.

    1 answer 1

    1) Redirect is used inside an anonymous method (or controller method)

     Route::get('/logout',function(){ \Auth::logout(); return redirect('/auth/login'); }); 

    2) In the second, you do something unique at all, and you are trying to specify a handler and an anonymous method to call, decide what should process the route.

    And the Council read the documentation first, just from beginning to end, so that you have a general idea of ​​how it all works.

    • Well, I read. I tried differently and your code was also in my attempts, but without using Auth :: logout () ;. Unfortunately, the code for some reason does not want to work. - aloe
    • and you generally made authorization? is there a way? What error does he give you? - Orange_shadow
    • Everything works now, you have a typo apparently, a single colon is worth it. Thank! - aloe