multi auth logout in laravel

72 0 0 0

Last Updated : 2021-02-27 00:29:13

how to create working logout function specially for multi auth in laravel or for the admins

at the adminLoginController (the controller you specified) add logout function as follows


public function logout() {
Auth::guard('admin')->logout(); // use guard name as you want
return view("default.adminAuth.adminLogin") ; // redirection
}

but the most important thing that you must do is tho make exception in middleware with admin guard to except logout function as follows


public function __construct() {
$this->middleware('guest:admin', ['except' => ['logout']] ) ; // note that there is an array inside another array & logout is the name of logout function
}

 

Mahmoud Anwar

Mahmoud Anwar

Back End Developer with a passion for developing innovative web applications that expedite the efficiency and effectiveness of organizational success. Well-versed in technology and writing code to create systems that are reliable and user-friendly. Also has the proven ability to motivate, educate, and collaborate effectively to build web applications and effectively track changes. Confident communicator, strategic thinker, and innovative creator to develop software that is customized to meet a company’s organizational needs, highlight their core competencies, and further their success.