Пример #1
0
 /**
  * Creates a new Patients model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($firm_id)
 {
     $model = new Patients();
     $firm = Firms::find()->where(['id' => $firm_id])->one();
     $model->firm_id = $firm->id;
     $model->firm = $firm->firm;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Пример #2
0
 /**
  * 
  * @param type $data
  */
 public static function add($data)
 {
     $patient = new Patients();
     $patient->attributes=$data;
     if($patient->save()) {
         return false;
     }
     $patient_errors=[];
     foreach ($patient->errors as $error) {
         $patient_errors[]=implode(', ',$error);
     }
     $errors=implode('<br> ',$patient_errors);
     return 'При сохранении пациента '.$patient->surname.' '.$patient->name.' '.$patient->patron.' возникли ошибки: '.$errors;
 }