Friday, 8 September 2017

2 ways to logout in laravel

There are 2 ways to logout from laravel.


1st way
Routing.
    Route::get('/logout', 'Auth\LoginController@logout');

 Blade file.
     <?php if(Auth::check()){ ?>
    <a href="{{ url('/logout') }}">Logout</a>
    <?php } ?>

2nd way
Routing.
      Route::post('logout','auth\LoginController@getLogout');

Controller.
     public function getLogout()
    {
        $this->auth->logout();
        return redirect('/login');
    }


Blade file.
 <?php if(Auth::check()){ ?>
<a href="{{ url('/logout') }}" class="btn-primary" style="padding:10px;" onclick="event.preventDefault();document.getElementById('logout-form').submit();"> Logout </a>
<form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
{{ csrf_field() }}</form>

   <?php } ?>

No comments:

Post a Comment

Machine Learning - Potato Leaf Disease Prediction

Step 1: import numpy as np import pandas as pd import splitfolders import matplotlib.pyplot as plt import tensorflow as tf from tensorflow i...