Example #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new CategoryAmenities();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['CategoryAmenities'])) {
         $model->attributes = $_POST['CategoryAmenities'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Example #2
0
 /**
  * This method gets arrary of data and creates the model
  * Returns Model if sucessfully created.
  * Returns the error Validated Model if validation fails
  *
  * Data arrary should have the following Hash keys
  * 1.amenity
  * 
  * @param arrary $data
  * @return model ||model with error
  */
 public static function create($data)
 {
     $categoryAmenties = new CategoryAmenities();
     $categoryAmenties->attributes = $data;
     return $categoryAmenties->save();
 }