/** * Creates a new Grades model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Grades(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->grade_id]); } else { return $this->render('create', [ 'model' => $model, ]); } }
/** * Creates a new Grades model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Grades(); // $test = ArrayHelper::map(Scholars::findBySql('SELECT * FROM scholars WHERE scholar_id=2')->all(),'scholar_id','scholar_lastName'); // $test2 = ArrayHelper::map(Scholars::findBySql('SELECT * FROM scholars WHERE scholar_id=3')->all(),'scholar_id','scholar_lastName'); // $test3 = array_values($test2)[0].' '.array_values($test)[0]; if ($model->load(Yii::$app->request->post())) { // $test4 = ArrayHelper::map(Scholars::find()->joinWith('grades')->where(['scholar_id'=>$model->grade_scholar_id])->all(),'scholar_id','scholar_lastName'); // $test5 = array_values($test4)[0]; // $model->grade_scholar_lastName = $test5; $model->save(); return $this->redirect(['view', 'id' => $model->grade_id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Grades model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { if(Yii::$app->user->can('create-grades')) { $model = new Grades(); if ($model->load(Yii::$app->request->post())) { $model->uploaded_by = Yii::$app->user->identity->username; $model->save(); return $this->redirect(['view', 'id' => $model->grade_id]); } else { return $this->render('create', [ 'model' => $model, ]); } } else { throw new ForbiddenHttpException; } }