/** * Ability to add sda in schedule */ public function actionAddsda() { $sdaattendee = new SdaSchedules(); if (Yii::$app->request->post()) { $value = \Yii::$app->request->post(); $userid = User::findOne(['id' => $value['userid']]); if ($userid) { $sdaid = $value['sdaid']; $congress = $value['congress']; $sdaattendee->attendee_id = $userid->attendee_id; $sdaattendee->sda_id = $sdaid; $sdaattendee->congress_id = $congress; $checksdaattendee = SdaSchedules::findOne(['attendee_id' => $userid->attendee_id, 'sda_id' => $sdaid, 'congress_id' => $congress]); if ($checksdaattendee) { echo "Attendee is already assigned for SDA Congress"; } else { try { $sdaattendee->save(false); echo "SDA Added Successfully"; } catch (Exception $exc) { echo $sdaattendee->getErrors(); } } } else { echo "User is not exist in Contect List"; } } }
/** * Finds the SdaSchedules model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SdaSchedules the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SdaSchedules::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }