/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $studentEvidenceStatus, $student = true)
 {
     $dataArray = ['student_evidence.status' => $studentEvidenceStatus, 'task.name' => $this->task_name, 'task.delivery_data' => $this->task_delivery_date];
     if ($student) {
         $dataArray['student.user_id'] = Yii::$app->user->id;
     } else {
         $dataArray['project.manager_id'] = 2;
     }
     $query = StudentEvidence::find();
     $query->joinWith(['evidence', 'task', 'project', 'student']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere($dataArray);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Downloads selected file
  * @param $evidenceId
  */
 public function actionDownload($evidenceId)
 {
     $studentEvidence = StudentEvidence::find()->where("evidence_id=" . $evidenceId)->one();
     return Yii::$app->response->sendFile(Yii::getAlias('@webroot') . $studentEvidence->evidence->attachment_path, $studentEvidence->evidence->attachment_name)->send();
 }