public function result($id) { $datastore = new Survey(); $survey = $datastore->get(['id' => $id])->First(); $this->viewData['survey'] = $survey; $datastore = new SurveyChoice(); $choices = $datastore->get(['surveyId' => $id])->ToArray(); $this->viewData['choices'] = $choices; $voteCount = 0; foreach ($choices as $choice) { $voteCount += $choice->getCount(); } $this->viewData['voteCount'] = $voteCount; return $this->view("Result"); }
public function view($id) { if ($identity = Identity::find($id)) { $surveys = []; foreach ($identity->answers as $answer) { $survey = Survey::find($answer['survey_id']); array_push($surveys, $survey); } return view('admin.identity.view', ['identity' => $identity, 'surveys' => $surveys]); } return redirect('admin/identity'); }
/** * Finds the Survey model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @param integer $Administrator_id * @return Survey the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Survey::findOne(['id' => $id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getEnableSurvey() { return Survey::find()->where(['is_enable' => 1])->asArray()->all(); }
/** * @return \yii\db\ActiveQuery */ public function getSurvey() { return $this->hasOne(Survey::className(), ['id' => 'Survey_id']); }
/** * @return \yii\db\ActiveQuery */ public function getSurveys() { return $this->hasMany(Survey::className(), ['id' => 'Survey_id'])->viaTable('Survey_has_Participant', ['Participant_id' => 'id']); }
public function index() { return view('admin.survey.index', ['surveys' => Survey::all()]); }
public function repeat($id) { if ($survey = Survey::find($id)) { $survey->repeat = !$survey->repeat; $survey->active = $survey->repeat ? true : $survey->active; $survey->save(); } return redirect('admin/survey'); }