Пример #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 actionIndex()
 {
     $razzModel = new Razz();
     $razzSearch = new RazzSearch();
     // FIXME [?] if needed
     $razzSearch->freshOnly = true;
     $object = false;
     $i = 0;
     while (!$object) {
         $id = $razzModel->getRazzRandom($fresh = true);
         $object = $razzModel->getRazz($id, $fresh);
         $i++;
         if ($i > 50) {
             break;
         }
     }
     if (!$object || !$object['responder_uid']) {
         return $this->render('/razz/view', []);
         //throw new NotFoundHttpException('Razzd not found');
     }
     $razzModel->toch($id);
     $commentModel = new Comments();
     $commentModel->eid = $id;
     return $this->render('/razz/view', ['commentModel' => $commentModel, 'razzModel' => $razzModel, 'razzSearch' => $razzSearch, 'object' => $object]);
 }