Second Commit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

85 lines
2.6 KiB

  1. <?php
  2. namespace App\Http\Controllers\Auth;
  3. use App\Http\Controllers\Controller;
  4. use App\Providers\RouteServiceProvider;
  5. use App\Models\UserAccount;
  6. use Illuminate\Foundation\Auth\RegistersUsers;
  7. use Illuminate\Support\Facades\Hash;
  8. use Illuminate\Support\Facades\Validator;
  9. class RegisterController extends Controller
  10. {
  11. /*
  12. |--------------------------------------------------------------------------
  13. | Register Controller
  14. |--------------------------------------------------------------------------
  15. |
  16. | This controller handles the registration of new users as well as their
  17. | validation and creation. By default this controller uses a trait to
  18. | provide this functionality without requiring any additional code.
  19. |
  20. */
  21. use RegistersUsers;
  22. /**
  23. * Where to redirect users after registration.
  24. *
  25. * @var string
  26. */
  27. protected $redirectTo = RouteServiceProvider::HOME;
  28. /**
  29. * Create a new controller instance.
  30. *
  31. * @return void
  32. */
  33. public function __construct()
  34. {
  35. $this->middleware('guest');
  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', 'string', 'max:255'],
  47. 'tanggal_lahir' => ['required', 'date:d/m/Y'],
  48. 'tempat_lahir' => ['required', 'string', 'max:255'],
  49. 'email' => ['required', 'string', 'email', 'max:255', 'unique:user_accounts'],
  50. 'handphone' => ['required', 'string', 'max:255'],
  51. 'jenis_kelamin' => ['required', 'string', 'max:255'],
  52. 'agama' => ['required', 'string', 'max:255'],
  53. 'password' => ['required', 'string', 'min:8', 'confirmed'],
  54. ]);
  55. }
  56. /**
  57. * Create a new user instance after a valid registration.
  58. *
  59. * @param array $data
  60. * @return \App\Models\UserAccount
  61. */
  62. protected function create(array $data)
  63. {
  64. return UserAccount::create([
  65. 'name' => $data['name'],
  66. 'tanggal_lahir' => $data['tanggal_lahir'],
  67. 'tempat_lahir' => $data['tempat_lahir'],
  68. 'email' => $data['email'],
  69. 'handphone' => $data['handphone'],
  70. 'jenis_kelamin' => $data['jenis_kelamin'],
  71. 'agama' => $data ['agama'],
  72. 'password' => Hash::make($data['password']),
  73. ]);
  74. }
  75. }