/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = RraDocfiles::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(['rra_docfiles_id' => $this->rra_docfiles_id, 'id_docfiles' => $this->id_docfiles, 'id_recoveryrecieveakt' => $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 getRraDocfiles() { return $this->hasMany(RraDocfiles::className(), ['id_recoveryrecieveakt' => 'recoveryrecieveakt_id'])->from(['RraDocfiles' => RraDocfiles::tableName()]); }
/** * Finds the RraDocfiles model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $id * @return RraDocfiles the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = RraDocfiles::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getRraDocfiles() { return $this->hasMany(RraDocfiles::className(), ['id_docfiles' => 'docfiles_id'])->from(['rraDocfiles' => RraDocfiles::tableName()]); }
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; }