Answers for "make logout in laravel in other pages"

PHP
3

laravel logout

//make a route as a post and button should look like this
 <form action="{{ route('logout') }}" method="post">
       @csrf
       <button type="submit">Logout</button>
</form>
//Controller will be like this.
public function store(){
        auth()->logout();
        return redirect()->route('home');
    }
Posted by: Guest on September-04-2021
0

laravel logout redirect

This is how I did it. In Auth\LoginController you have:

use AuthenticatesUsers;
Change it to:

use AuthenticatesUsers {
    logout as performLogout;
}
Then, define a new logout() method in your LoginController:

public function logout(Request $request)
{
    $this->performLogout($request);
    return redirect()->route('your_route');
}
Sure, regular logout() method in that trait has only 3 lines (used to log users out of the system) so you can copy them to your method, but you should always follow the DRY principle (don't repeat yourself) and re-use as much code as you can.
Posted by: Guest on March-23-2021

Browse Popular Code Answers by Language