Пример #1
0
 /**
  * view detail of news
  * @param int $id
  */
 public function actionView($id)
 {
     $model = Support::find()->where(['id' => $id])->one();
     $model->view_count = $model->view_count + 1;
     $model->save();
     return $this->render('view', array('model' => $model));
 }
Пример #2
0
 public function _getTopSupports()
 {
     $supports = Support::find()->orderBy('created_date DESC')->limit(5)->all();
     $html = '';
     foreach ($supports as $support) {
         $html .= '<li><a href="' . Yii::$app->params['site_url'] . 'support/' . urlencode($support->title) . '-' . $support->id . '">' . $support->title . '</a></li>';
     }
     return $html;
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Support::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'view_count' => $this->view_count, 'featured' => $this->featured, 'updated_date' => $this->updated_date, 'created_date' => $this->created_date]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'meta_keyword', $this->meta_keyword])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'meta_title', $this->meta_title]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Finds the Support model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Support the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Support::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }