AuthController.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\User;
  4. use Validator;
  5. use App\Http\Controllers\Controller;
  6. use Illuminate\Foundation\Auth\ThrottlesLogins;
  7. use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
  8. class AuthController extends Controller
  9. {
  10. /*
  11. |--------------------------------------------------------------------------
  12. | Registration & Login Controller
  13. |--------------------------------------------------------------------------
  14. |
  15. | This controller handles the registration of new users, as well as the
  16. | authentication of existing users. By default, this controller uses
  17. | a simple trait to add these behaviors. Why don't you explore it?
  18. |
  19. */
  20. use AuthenticatesAndRegistersUsers, ThrottlesLogins;
  21. /**
  22. * Where to redirect users after login / registration.
  23. *
  24. * @var string
  25. */
  26. //protected $redirectTo = '/admin/projects';
  27. protected $redirectTo = '/admin/check_user';
  28. /**
  29. * Create a new authentication controller instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct()
  34. {
  35. $this->middleware($this->guestMiddleware(), ['except' => 'logout']);
  36. }
  37. /**
  38. * Get a validator for an incoming registration request.
  39. *
  40. * @param array $data
  41. * @return \Illuminate\Contracts\Validation\Validator
  42. */
  43. protected function validator(array $data)
  44. {
  45. return Validator::make($data, [
  46. 'name' => 'required|max:255',
  47. 'email' => 'required|email|max:255|unique:users',
  48. 'password' => 'required|min:6|confirmed',
  49. 'utype' => 'required',
  50. ]);
  51. }
  52. /**
  53. * Create a new user instance after a valid registration.
  54. *
  55. * @param array $data
  56. * @return User
  57. */
  58. protected function create(array $data)
  59. {
  60. return User::create([
  61. 'name' => $data['name'],
  62. 'email' => $data['email'],
  63. 'utype' => $data['utype'],
  64. 'password' => bcrypt($data['password']),
  65. ]);
  66. //var_dump($data);
  67. }
  68. }