/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = RramatDocfiles::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $query->joinWith('idDocfiles'); $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; } // grid filtering conditions $query->andFilterWhere(['rramat_docfiles_id' => $this->rramat_docfiles_id, 'id_docfiles' => $this->id_docfiles, 'id_recoveryrecieveaktmat' => $params['id']]); $query->andFilterWhere(['LIKE', 'idDocfiles.docfiles_ext', $this->getAttribute('idDocfiles.docfiles_ext')]); $query->andFilterWhere(['LIKE', 'idDocfiles.docfiles_name', $this->getAttribute('idDocfiles.docfiles_name')]); $query->andFilterWhere(['LIKE', 'idDocfiles.docfiles_hash', $this->getAttribute('idDocfiles.docfiles_hash')]); Proc::AssignRelatedAttributes($dataProvider, ['idDocfiles.docfiles_ext', 'idDocfiles.docfiles_name', 'idDocfiles.docfiles_hash']); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getRramatDocfiles() { return $this->hasMany(RramatDocfiles::className(), ['id_recoveryrecieveaktmat' => 'recoveryrecieveaktmat_id'])->from(['RramatDocfiles' => RramatDocfiles::tableName()]); }
/** * @return \yii\db\ActiveQuery */ public function getRramatDocfiles() { return $this->hasMany(RramatDocfiles::className(), ['id_docfiles' => 'docfiles_id'])->from(['rramatDocfiles' => RramatDocfiles::tableName()]); }
/** * Finds the RramatDocfiles model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return RramatDocfiles the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = RramatDocfiles::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public static function DeleteDocFile($docfile_id) { if (!empty($docfile_id)) { $existdb1 = RraDocfiles::find()->andWhere(['id_docfiles' => $docfile_id])->count(); $existdb2 = RramatDocfiles::find()->andWhere(['id_docfiles' => $docfile_id])->count(); if (empty($existdb1) && empty($existdb2)) { $Docfiles = Docfiles::findOne($docfile_id); if (!empty($Docfiles)) { $hash = Yii::$app->basePath . '/docs/' . $Docfiles->docfiles_hash; $fileroot = DIRECTORY_SEPARATOR === '/' ? $hash : mb_convert_encoding($hash, 'Windows-1251', 'UTF-8'); if ($Docfiles->delete() && file_exists($fileroot)) { return unlink($fileroot); } } } } return false; }