/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Lunbo::find()->orderBy('status desc,id desc'); $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, 'create_at' => $this->create_at, 'update_at' => $this->update_at]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'url', $this->url])->andFilterWhere(['like', 'status', $this->status])->andFilterWhere(['like', 'order', $this->order]); return $dataProvider; }
/** * 获取启动页 * @return array */ public static function cms_qidong() { $lunbo = Lunbo::find()->select(['title', 'url', 'order', 'info', 'content', 'event_link'])->where(['status' => Lunbo::STATUS_SUCCESS, 'type' => Lunbo::TYPE_QIDONG])->orderBy('order desc,id desc')->asArray()->all(); if (!empty($lunbo)) { $data = array('list' => $lunbo); $result = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data); return $result; } else { $result = array('errorNum' => '1', 'errorMsg' => '暂无图片', 'data' => null); return $result; } }