Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Carousel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'is_target_self' => $this->is_target_self, 'carousel_order' => $this->carousel_order, 'status' => $this->status, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]);
     $query->andFilterWhere(['like', 'image_path', $this->image_path])->andFilterWhere(['like', 'image_link', $this->image_link])->andFilterWhere(['like', 'caption', $this->caption])->andFilterWhere(['like', 'created_by', $this->created_by])->andFilterWhere(['like', 'modified_by', $this->modified_by]);
     return $dataProvider;
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Carousel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'images_num' => $this->images_num, 'product_id' => $this->product_id, 'user_id' => $this->user_id]);
     $query->andFilterWhere(['like', 'images_label', $this->images_label])->andFilterWhere(['like', 'header', $this->header])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
 public function actionIndex()
 {
     //处理本页面按钮操作
     $request = Yii::$app->request;
     if ($op = $request->get('op')) {
         $id = $request->get('id');
         $carousel = Carousel::find()->where(['id' => $id])->one();
         if ($op == 'p') {
             $carousel->status = Carousel::STATUS_PUBLISHED;
         }
         if ($op == 'up') {
             $carousel->status = Carousel::STATUS_UN_PUBLISHED;
         }
         if ($op == 'd') {
             $carousel->status = Carousel::STATUS_DELETE;
         }
         $carousel->save(false);
     }
     $query = Carousel::find()->where("status != -1");
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $carousels = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['rows' => $carousels, 'pagination' => $pagination, 'page' => Yii::$app->request->get('page')]);
 }
 public function actionIndex()
 {
     //获取轮播图
     $this->view_data['carousel'] = Carousel::find()->where("status = 1")->asArray()->all();
     return $this->render("index", $this->view_data);
 }
Beispiel #5
0
 public function actionIndex()
 {
     $carousel = Carousel::find()->all();
     return $this->render('index', ['carousel' => $carousel]);
 }