示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Attachments::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(['document_id' => $this->document_id, 'size' => $this->size]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'ext', $this->ext]);
     return $dataProvider;
 }
示例#2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Attachments::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, 'regulations_id' => $this->regulations_id, 'created' => $this->created]);
     $query->andFilterWhere(['like', 'attachlabel', $this->attachlabel]);
     return $dataProvider;
 }
 /**
  * Lists all Hosts models.
  * @return mixed
  */
 public function actionIndex()
 {
     //        $dataProvider = new ActiveDataProvider([
     //            'query' => Hosts::find(),
     //        ]);
     $userId = $_GET['id'];
     $model = new UploadImagesForm();
     if ($model->load(Yii::$app->request->post())) {
         $model->imageFiles = UploadedFile::getInstances($model, 'imageFiles');
         if ($model->upload($userId)) {
             $newmodel = Attachments::find()->where(['user_id' => $userId])->all();
             return $this->render('index', ['model' => $model, 'formState' => 1, 'userId' => $userId, 'newmodel' => $newmodel]);
         }
     } else {
         $newmodel = Attachments::find()->where(['user_id' => $userId])->all();
         return $this->render('index', ['model' => $model, 'formState' => 0, 'userId' => $userId, 'newmodel' => $newmodel]);
     }
 }