示例#1
0
 /**
  * Get the particular razzd; output on individual screen
  * @param $id
  * @return mixed
  * @throws NotFoundHttpException
  */
 public function actionView($id)
 {
     $razzModel = new Razz();
     $razzSearch = new RazzSearch();
     $razzModel->toch($id);
     $object = $razzModel->getRazz($id);
     if (!$object || !$object['responder_uid']) {
         throw new NotFoundHttpException('Razzd not found');
     }
     $razzModel->end($object);
     $commentModel = new Comments();
     $commentModel->eid = $id;
     if ($commentModel->load(Yii::$app->request->post()) && $commentModel->save()) {
         if (Yii::$app->request->isAjax) {
             return $this->renderPartial('comments', ['model' => $commentModel]);
         }
         return $this->redirect(['/razz/' . $id]);
     }
     return $this->render('view', ['commentModel' => $commentModel, 'razzModel' => $razzModel, 'razzSearch' => $razzSearch, 'object' => $object]);
 }
示例#2
0
 public function getComments()
 {
     return $this->hasMany(Comments::className(), ['product_id' => 'id'])->andWhere(['is_approved' => '1']);
 }