/** * 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; }
/** * 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]); } }
/** * @return \yii\db\ActiveQuery */ public function getAttachments() { return $this->hasMany(Attachments::className(), ['regulations_id' => 'id']); }
/** * Finds the Attachments model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Attachments the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Attachments::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }