Putu Dika
Putu Dika

Reputation: 1

How to change logout method to GET in laravel 6?

I'm using laravel 6 and I want to change the method of logout auth. How I can do that?

I run :

php artisan route:list

and I get default laravel logout method is POST :

Route::post('/logout', 'LoginController@logout');

and I want change to GET :

Route::get('/logout', 'LoginController@logout');

How I can change the route method ? And where I can custom the logout controller ?

Upvotes: 0

Views: 927

Answers (1)

djunehor
djunehor

Reputation: 961

In your routes.php, add Route::get('/logout', 'LoginController@logout'); to the top of Auth::routes() so it overrides the default logout route.

In your LoginController@logout() method: simply do auth()->logout() and redirect as appropriate

Upvotes: 3

Related Questions