public function actionAddmentorentrepreneur()
 {
     $searchModel = new EntrepreneurSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $model = new MentorEntrepreneur();
     $selected = Yii::$app->request->post('selected');
     $mentor = Yii::$app->request->post('mentor');
     if (Yii::$app->request->isPost) {
         $users_id = explode(',', $selected);
         foreach ($users_id as $key => $value) {
             $temp[] = [$mentor, $value];
         }
         Yii::$app->db->createCommand()->batchInsert('mentor_entrepreneur', ['mentor_id', 'entrepreneur_user_id'], $temp)->execute();
         //Yii::$app->db->createCommand()->insert('mentor_entrepreneur',['mentor_id'=>$mentor,'entrepreneur_id'=>$selected])->execute();
         Yii::$app->session->setFlash('success', 'Your request has been successfully processed');
         return $this->redirect(['index']);
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Ejemplo n.º 2
0
 /**
  * Lists all Entrepreneur models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new EntrepreneurSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }