You have to do an http post now so you can't just link to a url, which would be a get. Take a look at the scaffolded auth code to see how Taylor does it.
Aug 25, 2016
12
Level 11
Laravel 5.3 Logout MethodNotAllowed
I've upgraded from Laravel 5.2 to Laravel 5.3. Since the changes from GET to POST, I am getting an error for MethodNotAllowed. I was using the Authentication Scaffolding previously in 5.2 for my authentication part of the app.
Any help here?
Edit: Got it to work.
Level 11
The best way to implement this is:
<a href="{{ route('logout') }}" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">Logout</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">{{ csrf_field() }}</form>
Since Auth::routes() already comes with name routes, we are using the route() method for this case.
style="display: none;" can be left out as form usually do not show up if there are no visible input fields.
12 likes
Please or to participate in this conversation.