/**
  * Creates a new Horario model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($idexame)
 {
     $model = new Horario();
     $model->exame_idexame = $idexame;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['/exame/update', 'id' => $model->exame_idexame]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #2
0
 public function afterSave($insert, $changedAttributes)
 {
     if (sizeof($this->horarios) == 0) {
         $h1 = new Horario();
         $h1->descricao = '12:00h às 13:30h';
         $h1->inicio = '12:00:00';
         $h1->termino = '13:30:00';
         $h1->exame_idexame = $this->idexame;
         $h1->save();
         $h2 = new Horario();
         $h2->descricao = '14:00h às 15:30h';
         $h2->inicio = '14:00:00';
         $h2->termino = '15:30:00';
         $h2->exame_idexame = $this->idexame;
         $h2->save();
         $h3 = new Horario();
         $h3->descricao = '16:00h às 17:30h';
         $h3->inicio = '16:00:00';
         $h3->termino = '17:30:00';
         $h3->exame_idexame = $this->idexame;
         $h3->save();
         $h4 = new Horario();
         $h4->descricao = '18:00h às 19:30h';
         $h4->inicio = '18:00:00';
         $h4->termino = '19:30:00';
         $h4->exame_idexame = $this->idexame;
         $h4->save();
     }
     parent::afterSave($insert, $changedAttributes);
 }