Esempio n. 1
0
 public function register(Request $request)
 {
     $validate = validateuser::validate(Request::all());
     if ($validate->passes()) {
         $user = new Member();
         $user->email = $request::input('email');
         $user->password = \Hash::make($request::input('password'));
         $user->name = $request::input('name');
         $user->surname = $request::input('surname');
         $user->nickname = $request::input('nickname');
         $user->phone = $request::input('phone');
         $user->id_card = $request::input('id_card');
         $user->bank = $request::input('bank');
         $user->account_no = $request::input('account');
         $user->education = $request::input('education');
         $user->institute = $request::input('institute');
         $user->reference = $request::input('reference');
         $link = '';
         if ($user->save()) {
             $userinfo = $request::only('email', 'password');
             if (Auth::attempt($userinfo)) {
                 $link = '/';
             }
             //ส่ง email
             //จบส่ง email
         } else {
             $link = 'register';
         }
         return Redirect::to($link);
     } else {
         return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }
Esempio n. 2
0
 public function register(Request $request)
 {
     $validate = validateuser::validate(Request::all());
     //Generate validate code
     $validatecode = MD5(app('App\\Http\\Controllers\\Sendmail')->generateRandomString());
     if ($validate->passes()) {
         $input_birthday = explode("/", Request::input('birthday'));
         $birthday = $input_birthday[2] . "-" . $input_birthday[1] . "-" . $input_birthday[0];
         $user = new Member();
         $user->email = $request::input('email');
         $user->password = \Hash::make($request::input('password'));
         $user->name = $request::input('name');
         $user->surname = $request::input('surname');
         $user->nickname = $request::input('nickname');
         $user->phone = $request::input('phone');
         $user->id_card = $request::input('id_card');
         $user->birthday = $birthday;
         //$user->bank = $request::input('bank');
         //$user->account_no = $request::input('account');
         //$user->education = $request::input('education');
         //$user->institute = $request::input('institute');
         //$user->reference = $request::input('reference');
         //$user->address = $request::input('address');
         //$user->province = $request::input('province');
         /*if($request::input('province') != 69){
             $user->district = 0;
           }else{
             $user->district = $request::input('district');
           }*/
         $user->userstatus = 1;
         $user->permission = 1;
         $user->validate = 1000;
         $user->email_valid_code = $validatecode;
         $link = '';
         if ($user->save()) {
             $userinfo = $request::only('email', 'password');
             if (Auth::attempt($userinfo)) {
                 $link = 'poatregister';
             }
             //ส่ง email
             Sendverify::sendEmailReminder($request::input('name') . " " . $request::input('surname'), $request::input('email'), $validatecode);
             //จบส่ง email
         } else {
             $link = 'register';
         }
         //ตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป
         /*$countinstitute = institute::where('name', 'LIKE', $request::input('institute'))->count();
         
                     if($countinstitute < 1){
                         $institute = new institute();
                         $institute->name = $request::input('institute');
                         $institute->save();
                     }*/
         //จบตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป
         return Redirect::to($link);
     } else {
         return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }