User’s logout link in laravel

I am new to Laravel and have been having trouble with the following piece of code. The system is working properly up to this point, user registration/user login, but will not allow me to sign the user out.

<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>

 

 

Leave a Reply