Exemplo n.º 1
0
 public function actionCreateFromAssignation($id)
 {
     $model = new Incident();
     $model->solved = false;
     $model->user_id = Yii::$app->user->id;
     $assignationmodel = new Assignation();
     $assignationmodel = Assignation::findOne($id);
     $model->date = $assignationmodel->date;
     $model->equipment_id = $assignationmodel->equipment_id;
     $model->room_id = $assignationmodel->room_id;
     $model->location_id = $assignationmodel->location_id;
     $model->client_id = $assignationmodel->client_id;
     $this->layout = '/main2';
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view2', 'id' => $model->id]);
     } else {
         return $this->render('create2', ['model' => $model]);
     }
 }
 /**
  * Finds the Assignation model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Assignation the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Assignation::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }