Advertisement
adenhidayat

LoginController admin

Jan 19th, 2017
2,454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.67 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers\AdminAuth;
  4.  
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Foundation\Auth\AuthenticatesUsers;
  7. use Illuminate\Http\Request;
  8. use Auth;
  9.  
  10. class LoginController extends Controller
  11. {
  12.     /*
  13.     |--------------------------------------------------------------------------
  14.     | Login Controller
  15.     |--------------------------------------------------------------------------
  16.     |
  17.     | This controller handles authenticating users for the application and
  18.     | redirecting them to your home screen. The controller uses a trait
  19.     | to conveniently provide its functionality to your applications.
  20.     |
  21.     */
  22.  
  23.     use AuthenticatesUsers;
  24.  
  25.     /**
  26.      * Where to redirect users after login.
  27.      *
  28.      * @var string
  29.      */
  30.     protected $redirectTo = '/admin-home';
  31.  
  32.     /**
  33.      * Create a new controller instance.
  34.      *
  35.      * @return void
  36.      */
  37.     public function __construct()
  38.     {
  39.         $this->middleware('guest', ['except' => 'logout']);
  40.     }
  41.  
  42.     /**
  43.      * Show the application's login form.
  44.      *
  45.      * @return \Illuminate\Http\Response
  46.      */
  47.     public function showLoginForm()
  48.     {
  49.         return view('admin-auth.login');
  50.     }
  51.  
  52.      /**
  53.      * Get the guard to be used during authentication.
  54.      *
  55.      * @return \Illuminate\Contracts\Auth\StatefulGuard
  56.      */
  57.     protected function guard()
  58.     {
  59.         return Auth::guard('admin_user');
  60.     }
  61.  
  62.     public function logout(Request $request)
  63.     {
  64.         $this->guard()->logout();
  65.  
  66.         $request->session()->flush();
  67.  
  68.         $request->session()->regenerate();
  69.  
  70.         return redirect('/admin_login');
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement