Пример #1
0
 public function registerAction()
 {
     $model = new \modules\users\models\Users('register');
     $user_phone = new \modules\users\models\User_phones(false);
     $user_address = new \modules\users\models\User_addresses(false);
     $model->set('usergroup_id', 1);
     $model->set('fullname', $this->input->post('fullname'));
     $model->set('usergroup_id', $this->input->post('usergroup_id'));
     $model->set('email', $this->input->post('email'));
     $model->set('gender', $this->input->post('gender'));
     $model->set('password', md5($this->input->post('password')));
     $model->set('status', 'active');
     if ($r = $model->save()) {
         foreach ($this->input->post('phone') as $phone) {
             $user_phone->set('phone', $phone);
             $user_phone->set('user_id', $r);
             $user_phone->save();
         }
         foreach ($this->input->post('address') as $address) {
             $user_address->set('address', $address);
             $user_address->set('user_id', $r);
             $user_address->set('type', 'shipping');
             $user_address->save();
         }
         Uri_helper::redirect("users/thankyou");
     } else {
         return $this->render('users/register', ['menu' => ['male' => 'Male', 'female' => 'Female']]);
     }
 }