/** * @param $studentId * @param $task * @param $studentEvidence * @throws \yii\base\InvalidConfigException */ private function setNotification($studentId, $taskId, $proyectId, $description) { $notification = Yii::createObject(['class' => Notification::className(), 'user_id' => Student::findOne([$studentId])->user_id, 'description' => $description, 'role' => Notification::ROLE_STUDENT, 'created_at' => Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'), 'viewed' => false, 'url' => Url::to(['/student/student-evidence/view', 'task_id' => $taskId, 'project_id' => $proyectId, 'student_id' => $studentId])]); $notification->save(false); }
/** * Updates an existing StudentEvidence model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $evidence_id * @return mixed */ public function actionUpdate($evidence_id) { $studentEvidence = $this->findModelByEvidence($evidence_id); $evidence = $studentEvidence->evidence; if (Yii::$app->request->post()) { $params = Yii::$app->request->post(); $evidence->load($params); $evidence->file = UploadedFile::getInstance($evidence, 'file'); if (isset($evidence->file)) { if (is_file(Yii::getAlias('@webroot') . $evidence->attachment_path)) { unlink(Yii::getAlias('@webroot') . $evidence->attachment_path); } $this->saveEvidenceFile($evidence); } $evidence->update(false); //set notification $notification = Yii::createObject(['class' => Notification::className(), 'user_id' => ProjectManager::findOne([Project::findOne([$studentEvidence->project_id])->manager_id])->user_id, 'description' => Notification::EDITED_RECEIVED_TASK, 'role' => Notification::ROLE_STUDENT, 'created_at' => Yii::$app->formatter->asDate('now', 'yyyy-MM-dd'), 'viewed' => false, 'url' => Url::to(['/project_manager/task/show-feedback-screen', 'taskId' => $studentEvidence->task_id, 'evidenceId' => $evidence->id])]); $notification->save(false); return $this->redirect(['view', 'task_id' => $studentEvidence->task_id, 'project_id' => $studentEvidence->project_id, 'student_id' => $studentEvidence->student_id]); } else { return $this->render('update', ['studentEvidence' => $studentEvidence, 'evidence' => $evidence]); } }
/** * @return \yii\db\ActiveQuery */ public function getNotifications() { return $this->hasMany(Notification::className(), ['branch_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getNotifications() { return $this->hasMany(Notification::className(), ['postID' => 'postID']); }