Ejemplo n.º 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new PlaceReview();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['PlaceReview'])) {
         $model->attributes = $_POST['PlaceReview'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
Ejemplo n.º 2
0
 public function actionReview()
 {
     $message = false;
     $place = Place::model()->findByPk($_GET['id']);
     $host = Host::model()->findByPk($place['host_id']);
     $model = PlaceReview::model()->findByAttributes(array('place_id' => $_GET['id'], 'teacher_id' => $this->_user['masterId']));
     if (!count($model)) {
         $model = new PlaceReview();
     }
     if (isset($_POST['PlaceReview'])) {
         $model->attributes = $_POST['PlaceReview'];
         $model->place_id = $_GET['id'];
         $model->teacher_id = $this->_user['masterId'];
         if ($model->save()) {
             $message = true;
         }
     }
     $this->render('review', array('place' => $place, 'host' => $host, 'message' => $message, 'model' => $model));
 }