예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Show::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'catalog_id' => $this->catalog_id, 'user_id' => $this->user_id, 'click' => $this->click, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template', $this->template])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]);
     return $dataProvider;
 }
예제 #2
0
 public function actionShow()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if (0 >= $id) {
         $this->redirect(Yii::$app->homeUrl);
     }
     $show = Show::findOne(['id' => $id]);
     $catalog = Catalog::findOne(['id' => $show->catalog_id]);
     $templatePage = $show->template ? $show->template : $catalog->template_show ? $catalog->template_show : 'show';
     $portlet = Catalog::getCatalogSub2($id, Catalog::find()->all());
     $portletTitle = Catalog::findOne(['id' => Catalog::getRootCatalogId($id, Catalog::find()->all())])->title;
     return $this->render($templatePage, ['catalog' => $catalog, 'show' => $show, 'portlet' => $portlet, 'portletTitle' => $portletTitle]);
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getShows()
 {
     return $this->hasMany(Show::className(), ['catalog_id' => 'id']);
 }
예제 #4
0
 /**
  * Finds the Show model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Show the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Show::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }