AuthController.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Admin\Controllers\Admin;
  3. use Illuminate\Routing\Controller;
  4. use Illuminate\Support\Facades\Auth;
  5. class AuthController extends Controller
  6. {
  7. /**
  8. * Show the login page.
  9. *
  10. * @return \Illuminate\Contracts\View\Factory|Redirect|\Illuminate\View\View
  11. */
  12. public function getLogin()
  13. {
  14. if ($this->guard()->check()) {
  15. return redirect($this->redirectPath());
  16. }
  17. return view('admin.login');
  18. }
  19. /**
  20. * Get the post login redirect path.
  21. *
  22. * @return string
  23. */
  24. protected function redirectPath()
  25. {
  26. if (method_exists($this, 'redirectTo')) {
  27. return $this->redirectTo();
  28. }
  29. return property_exists($this, 'redirectTo') ? $this->redirectTo : config('admin.route.prefix');
  30. }
  31. /**
  32. * Get the guard to be used during authentication.
  33. *
  34. * @return \Illuminate\Contracts\Auth\StatefulGuard
  35. */
  36. protected function guard()
  37. {
  38. return Auth::guard('admin');
  39. }
  40. }