Beispiel #1
0
 /**
  * Creates a new Npn model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Npn();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'news_id' => $model->news_id, 'pending_news_id' => $model->pending_news_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 protected function linkNews($news_id, $pn_id)
 {
     try {
         $npn = new Npn();
         $npn->news_id = $news_id;
         $npn->pending_news_id = $pn_id;
         if ($npn->save()) {
             $news = News::findOne($news_id);
             $news->updateCounters(['cnt' => 1]);
             $this->detectCategories($news_id, $pn_id);
         }
     } catch (\Exception $e) {
         print_r($e->getMessage());
     }
 }