public function validateFieldsUnique($attribute, $params) { $modelAux = DisciplinaPeriodo::findOne(['idDisciplina' => $this->idDisciplina, 'codTurma' => $this->codTurma, 'anoPeriodo' => $this->anoPeriodo, 'numPeriodo' => $this->numPeriodo]); if ($modelAux != null) { if ($modelAux->id != $this->id) { $this->addError($attribute, 'O conjunto (Disciplina, Código Turma, Ano Período e Número Período) já existem no sistema.'); } } }
/** * Finds the DisciplinaPeriodo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return DisciplinaPeriodo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = DisciplinaPeriodo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function afterFind() { switch ($this->bolsa) { case 0: $this->traducao_bolsa = 'Não'; break; case 1: $this->traducao_bolsa = 'Sim'; break; } switch ($this->status) { case 0: $this->traducao_status = 'Aguardando Avaliação'; break; case 1: $this->traducao_status = 'Selecionado com bolsa'; break; case 2: $this->traducao_status = 'Selecionado sem bolsa'; break; case 3: $this->traducao_status = 'Não selecionado'; break; case 4: $this->traducao_status = 'Indeferido - Nota < 7'; break; case 5: $this->traducao_status = 'Indeferido - Coeficiente < 5'; break; case 6: $this->traducao_status = 'Indeferido - Não cursou a disciplina'; break; } $periodo = PeriodoInscricaoMonitoria::findOne(['id' => $this->IDperiodoinscr]); $this->IDperiodoinscr = $periodo->ano . '/' . $periodo->periodo; $disciplinaPeriodo = DisciplinaPeriodo::findOne($this->IDDisc); $disciplina = Disciplina::find()->where(['id' => $disciplinaPeriodo->idDisciplina])->one(); $this->nomeDisciplina = $disciplina->nomeDisciplina; $curso = Curso::find()->where(['id' => $disciplinaPeriodo->idCurso])->one(); $this->nomeCurso = $curso->nome; }