/** * Creates a new TestType model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new TestType(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store(TestTypeRequest $request) { $testtype = new TestType(); $testtype->name = trim($request->name); $testtype->description = $request->description; $testtype->test_category_id = $request->test_category_id; $testtype->targetTAT = $request->targetTAT; $testtype->prevalence_threshold = $request->prevalence_threshold; $testtype->orderable_test = $request->orderable_test; $testtype->accredited = $request->accredited; $testtype->save(); $measureIds = array(); $inputNewMeasures = $request->new_measures; $measures = new MeasureController(); $measureIds = $measures->store($inputNewMeasures); $testtype->setMeasures($measureIds); $testtype->setSpecimenTypes($request->specimentypes); $testtype->setOrganisms($request->organisms); $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('terms.record-successfully-saved'))->with('active_testtype', $testtype->id); }