Ejemplo n.º 1
0
 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->email;
         $user->email = $this->email;
         $user->status = User::STATUS_AWAITING_REQUEST;
         if ($user->save(false)) {
             $customer = new Customer();
             $customer->name = $this->company_name;
             $customer->location = $this->location;
             $customer->address = $this->address;
             $customer->zip_code = $this->zip_code;
             $customer->phone_number = $this->phone_number;
             $customer->website = $this->website;
             $customer->kvk = $this->kvk;
             $customer->btw = $this->btw;
             $customer->email_address = $this->email;
             $customer->description = $this->description;
             $customer->contact_type = $this->contact_type;
             $customer->contact = $this->contact;
             $customer->user_id = $user->id;
             if ($customer->save(false)) {
                 return $user;
             } else {
                 $user->delete();
             }
         }
     }
     return null;
 }
 /**
  * Creates a new Customer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->customer_id]);
     }
     return $this->render('create', ['model' => $model]);
 }
Ejemplo n.º 3
0
 /**
  * Creates a new EntpCustomer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Customer();
     if ($model->load(Yii::$app->request->post())) {
         $model->loadDefaultValues();
         $model->save();
         if ($model->save()) {
             $cust = new EntpCustomer();
             $cust->customer_id = $this->id;
             $cust->entrepreneur_user_id = Yii::$app->user->id;
             $cust->link('customer', $model);
         }
         Yii::$app->session->setFlash('success', 'Create New Customer Success');
         return $this->redirect(['index']);
         //return $this->redirect(['view', 'entrepreneur_user_id' => $model->entrepreneur_user_id, 'customer_id' => $model->customer_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Customer model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($uid = null, $email = null)
 {
     $model = new Customer();
     if (isset($uid)) {
         $model->user_id = $uid;
     }
     if (isset($email)) {
         $model->email_address = $email;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->customer_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }