Example #1
0
 /**
  * Finds the Download model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Download the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Download::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Download::find()->alive();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => [], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $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, 'column_id' => $this->column_id, 'hits' => $this->hits, 'order' => $this->order, 'status' => $this->status, 'deleted' => $this->deleted, 'updated_at' => $this->updated_at, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'flag', $this->flag])->andFilterWhere(['like', 'colorval', $this->colorval])->andFilterWhere(['like', 'boldval', $this->boldval])->andFilterWhere(['like', 'file_type', $this->file_type])->andFilterWhere(['like', 'language', $this->language])->andFilterWhere(['like', 'accredit', $this->accredit])->andFilterWhere(['like', 'file_size', $this->file_size])->andFilterWhere(['like', 'unit', $this->unit])->andFilterWhere(['like', 'run_os', $this->run_os])->andFilterWhere(['like', 'down_url', $this->down_url])->andFilterWhere(['like', 'source', $this->source])->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'link_url', $this->link_url])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'pic_url', $this->pic_url])->andFilterWhere(['like', 'picarr', $this->picarr]);
     return $dataProvider;
 }
Example #3
0
 /**
  * 一对多
  */
 public function getDownload()
 {
     return $this->hasMany(Download::className(), ['column_id' => 'id']);
 }