Use this in routes.php Route::get('auth/logout', 'Auth\AuthController@getLogout'); and add <a href="{{ url('/auth/logout') }}" >Logout</a> in your view . It's a builtin functionality. I mean Auth.
I also had similar problem in Laravel 5.2. You should change your route to
Route::get('auth/logout', 'Auth\AuthController@logout');
or in AuthController constructor add
public function __construct()
{
$this->middleware('guest', ['except' => ['logout', 'getLogout']]);
}
That worked for me.
Pawlox said:
I also had similar problem in Laravel 5.2. You should change your route to
Route::get('auth/logout', 'Auth\AuthController@logout');
or in AuthController constructor add
public function __construct() { $this->middleware('guest', ['except' => ['logout', 'getLogout']]); }
That worked for me.
Thank you , you save my life
Thank you too. I have been pulling my hair out.
Which is best practice?
Check this
https://laracasts.com/discuss/channels/laravel/logout-wont-work?page=1#reply-138472
you just need to fix your AuthController
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', [ 'except' => 'logout' ]); // Default router name is "logout" should be same router
}
Route::get('logout', [ 'uses' => 'Auth\AuthController@getLogout', 'as' => 'logout' ]);
Pawlox said:
I also had similar problem in Laravel 5.2. You should change your route to
Route::get('auth/logout', 'Auth\AuthController@logout');
or in AuthController constructor add
public function __construct() { $this->middleware('guest', ['except' => ['logout', 'getLogout']]); }
That worked for me.
Thanks, bro! Much appreciated!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community