jeudi 31 août 2017

Laravel 5.4 Set All Authentication Routes Except Logout Route - Using Custom Logout Route/Controller

So for some reason I thought I came across the answer to this question before, but for the life of me I can't find the answer again, either through Google or StackOverflow. This might just be a rubber duck question and I'm sorry if it is, but I hope this question will be of some use to someone someday with this same issue.

Let's assume we're starting with a fresh installation of Laravel 5.4. I run the php artisan make:auth command in my terminal and it sets up the Authentication Scaffolding for me. Now in my /routes/web.php file I see the following line:

Auth::routes();

Which is awesome and the route list has all the Authentication routes listed including the logout route defined. (Typed php artisan r:l to double check) Now I want to set a custom logout route for the user using the a custom Logout Controller. Now, I thought that there was a method you could chain onto a route called 'except()' but for the life of me I can't find any information in the documentation about this method. I don't know if this method even exists let alone know what to pass it.

So the question is simple. How do I include all authentication routes except the logout route, and then i'll define the logout route using the following line.

Route::get('logout', 'LogoutController@userLogout')->name('logout');

Sorry if this is a duplicate entry, I've used the search bar for the past hour and nothing is answering my question.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire