예제 #1
0
 /**
  * @param integer $physicianId
  * @return mixed
  */
 public function actionUpdate($physicianId)
 {
     $physician = Physician::findOne($physicianId);
     $receptions = Reception::findAll(['physician_id' => $physicianId]);
     if (Yii::$app->request->post('Reception') !== null) {
         Reception::deleteAll(['physician_id' => $physicianId]);
         foreach (Yii::$app->request->post('Reception') as $item) {
             $model = new Reception();
             $model->physician_id = $physicianId;
             $model->locality_id = $item['locality'];
             $model->weekday = $item['weekday'];
             $model->hour = (int) $item['hour'];
             $model->minute = (int) $item['minute'];
             $model->save();
         }
         return $this->redirect(['/appointment/physician/view', 'id' => $physicianId]);
     } else {
         $codes = [];
         foreach ($physician->receptions as $reception) {
             $codes[] = $reception->code;
         }
         return $this->render('update', ['model' => new Reception(), 'physician' => $physician, 'codes' => $codes]);
     }
 }
예제 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReceptions()
 {
     return $this->hasMany(Reception::className(), ['physician_id' => 'physician_id']);
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getReceptions()
 {
     return $this->hasMany(Reception::className(), ['locality_id' => 'locality_id']);
 }