예제 #1
0
 public function actionMyPlace()
 {
     $placeCriteria = new CDbCriteria();
     $placeBookingCriteria = new CDbCriteria();
     $placeReviewCriteria = new CDbCriteria();
     //我的场地
     $placeCriteria->order = 'id DESC';
     $placeCriteria->addCondition("host_id = '{$this->_cookiesGet('userId')}'");
     $place = Place::model()->find($placeCriteria);
     //客户评分
     $placeReviewCriteria->order = 'id DESC';
     $placeReviewCriteria->addCondition("place_id = '{$place['id']}'");
     $placeReview = PlaceReview::model()->findAll($placeReviewCriteria);
     //场地信息
     //$placeBookingCriteria->select = "'t.*'";
     //$placeBookingCriteria->join = 'LEFT JOIN seed_place_booking as sl ON t.id=sl.teacher_id';
     //$placeBookingCriteria->addCondition('sl.place_id=:place_id');
     //$placeBookingCriteria->params[':place_id']=$place->id;
     //场地信息分页
     //$count = Teacher::model()->count($placeBookingCriteria);
     //$pager = new CPagination($count);
     //$pager->pageSize = 5;
     //$pager->applyLimit($placeBookingCriteria);
     $teachers = $this->getTeachers($place->id);
     $this->render('myPlace', array('place' => $place, 'teachers' => $teachers, 'placeReview' => $placeReview, 'status' => $this->isStatus()));
 }
예제 #2
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return PlaceReview the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = PlaceReview::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #3
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));
 }
예제 #4
0
 public function getReviews()
 {
     return $this->hasMany(PlaceReview::className(), ['place_id' => 'id'])->addOrderBy(["created" => SORT_DESC])->setModelScenario(PlaceReview::SCENARIO_LIMITED);
 }