In this tutorial, we will learn how to create logout.


Step 1 : Create logout button on dashboard page (successlogin.blade.php).

<a href="{{url('/main/logout')}}">Logout</a>


We will also check if the user has logged in. So he could not go to the dashboard page without login. For this, we will create a if else condition in dashboard view page, in which we will check that if the user is not logged in then he cannot return to the dashboard page untill he login.

Complete code of dashboard page :

<!-- Here i am checking user login or not -->      

  <div class="alert alert-success success-block" style="text-align: center;">
         Welcome : {{ Auth::user()->name }} <br> 
        <p>Your email is : {{ Auth::user()->email }} </p><br>

        <!-- Create logout button here --> 
        <a href="{{url('/main/logout')}}">Logout</a>






Step 2 : Open your main controller and create logout function.

function logout()


	return redirect('main');



Step 3 : Now create a route  in web.php for logout and redirect to main.




Result :

Source Code:

Small Laravel Project

In this project. We are providing you, how to create small project in Laravel....

Source Code