Ejemplo n.º 1
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-10
  * Send payment_email
  */
 public function send(Request $request)
 {
     //Check Status
     if ($this->_stop) {
         return Redirect::intended(url($this->_redirectTo));
     }
     $post = $request->all();
     $sign_contract = $this->trim_all($post['sign_contract']);
     //Setup validation
     $validator = Validator::make($sign_contract, ['email' => 'required|email|min:5|max:100', 'agree' => 'required']);
     //Checking
     if ($validator->fails()) {
         // The given data did not pass validation
         //set Flash Message
         $this->setFlash('message', 'Errors!');
         return redirect()->back();
     }
     $user = new \App\User();
     if ($user->checkExistedPaymentEmail($this->_user_id, $sign_contract['email'])) {
         //set Flash Message
         $this->setFlash('message', 'This email is not available!');
         return Redirect::intended(url('/dashboard'));
     }
     //contract_file
     $contract_file = \App\Config::where(['prefix' => 'site', 'name' => 'contract_file', 'del_flg' => 1])->get()[0]['value'];
     //Create confirmation link
     $match = new Libraries\Math();
     $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
     $this->_user->confirm_payment_code = $match->to_base(rand(10, 30) . substr(time(), 5, 10) . rand(10, 30), 62) . $this->encryptString(rand(111, 999) . rand(1111, 9999), $salt) . $this->encryptString(time(), $salt) . $match->to_base(rand(10, 30) . substr(time(), 5, 10) . rand(10, 30), 62);
     $this->_user->payment_email = $sign_contract['email'];
     $this->_user->contract_file = $contract_file;
     $this->_user->save();
     //Send mail
     $this->_sendMailSignContract();
     //set Flash Message
     $this->setFlash('message', 'Please confirm payment from email ' . $sign_contract['email'] . '!');
     return Redirect::intended('/dashboard/sign_contract')->with('message', 'Please confirm from email ' . $sign_contract['email'] . '!');
 }
Ejemplo n.º 2
0
 /**
  * @author: lmkhang - skype
  * @date: 2015-12-30
  * Register USER
  */
 public function create_registration(Request $request)
 {
     //Check isLogged
     if ($this->isLogged()) {
         die;
     }
     //Post
     $post = $request->all();
     $register = $post['register'];
     //Trim
     $register = $this->trim_all($register);
     //Setup validation
     $validator = Validator::make($register, ['username' => array('required', 'regex: /^\\w{5,50}$/'), 'pin_code' => 'required|min:6|max:6|digits:6', 'email' => 'required|email|min:5|max:100', 'password' => 'required|min:5|max:50', 'repeat_password' => 'required|same:password', 'first_name' => 'required|min:2|max:50', 'last_name' => 'required|min:2|max:50']);
     // Optionally customize this version using new ->after()
     /*$validator->after(function() use ($validator) {
                 // Do more validation
     
                 $validator->errors()->add('field', 'new error');
             });*/
     //Checking
     if ($validator->fails()) {
         // The given data did not pass validation
         //            $session = new \Symfony\Component\HttpFoundation\Session\Session();
         //            $session->set('messages', $validator->errors());
         //set Flash Message
         $this->setFlash('message', 'Errors!');
         return redirect()->back();
     }
     //Check some existed attributes
     $registration_system = config('constant.registration');
     $msg_attributes = $this->checkUserAttributes($register, $registration_system['site']);
     if ($msg_attributes) {
         //set Flash Message
         $this->setFlash('message', 'Errors!');
         return redirect()->back();
     }
     //Success
     unset($register['repeat_password']);
     $match = new Libraries\Math();
     $register['refer'] = $match->to_base(rand(10, 30) . substr(time(), 5, 10) . rand(10, 30), 62) . $match->to_base(rand(100, 300) . substr(time(), 5, 10) . rand(100, 300), 62) . $match->to_base(rand(100, 300) . substr(time(), 5, 10) . rand(100, 300), 62);
     $salt = \App\Config::where(['prefix' => 'site', 'name' => 'salt', 'del_flg' => 1])->get()[0]['value'];
     $user = new \App\User();
     $user->refer = $register['refer'];
     $user->from_refer = $register['from_refer'];
     $user->password = $this->encryptString($register['password'], $salt);
     $user->username = $register['username'];
     $user->pin_code = $this->encryptString($register['pin_code'], $salt);
     $user->active_code = $match->to_base(rand(10, 30) . substr(time(), 5, 10) . rand(10, 30), 62) . $this->encryptString(rand(111, 999) . rand(1111, 9999), $salt) . $this->encryptString(time(), $salt) . $match->to_base(rand(10, 30) . substr(time(), 5, 10) . rand(10, 30), 62);
     $user->first_name = $register['first_name'];
     $user->last_name = $register['last_name'];
     $user->email = $register['email'];
     $user->save();
     //Insert User Stats
     $user_stats = new \App\UserStats();
     $user_stats->user_id = $user->user_id;
     $user_stats->total = 0;
     $user_stats->save();
     //Send mail
     $this->_sendmail_registration($user);
     //set Flash Message
     $this->setFlash('message', 'Please confirm from email ' . $register['email'] . '!');
     return Redirect::intended('/')->with('message', 'Please confirm from email ' . $register['email'] . '!');
 }