示例#1
0
 /**
  * This method accepts a userId and an array of data to creates the Agent profile model.
  * Returns true if successfully created.
  * Returns the error validated model if validation fails.
  *
  * data array should have the following hash keys -
  * 1. id (optional)
  * 2. company_name
  * 3. company_description
  * 4. address_line1
  * 5. address_line2
  * 6. country_id
  * 7. state_id
  * 8. city_id
  * 9. mobile
  * 10. telephone
  * 11. email
  *
  * @param string $userId
  * @param array $data
  * @return model|model
  */
 public static function createAgentProfile($userId, $data)
 {
     /*if (is_null ( $data ) || is_null ( trim ( $userId ) ))
     		return false;
     		*/
     $userAgentProfile = new UserAgentProfile();
     $userAgentProfile->attributes = $data;
     $userAgentProfile->user_id = $userId;
     $userAgentProfile->save();
     return $userAgentProfile;
 }
示例#2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new UserAgentProfile();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['UserAgentProfile'])) {
         $model->attributes = $_POST['UserAgentProfile'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }