/** * Creates a new Parttimejobs model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $username=Yii::$app->user->identity->username; $users = User::find()->all(); $scholars = Scholars::find()->all(); $model = new Parttimejobs(); foreach($users as $user){ foreach($scholars as $scholar){ if($user->username==$username&&$user->id==$scholar->scholar_id){ $model->job_scholar_id=$scholar->scholar_id; if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index', 'id' => $model->id]); } else { return $this->render('create', [ 'model' => $model, ]); } } } } }