Esempio n. 1
0
 /**
  * @return bool
  */
 public function createManager()
 {
     if ($this->validate() && ($user_id = $this->getUserIdByUsername())) {
         $model = new Manager();
         $model->user_id = $user_id;
         $model->status = 1;
         $model->created_at = time();
         $model->updated_at = time();
         if ($model->save()) {
             return true;
         }
         return false;
     }
 }
 /**
  * Creates a new Manager model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Manager();
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $user_id = Yii::$app->request->post('user_id');
         $userModel = User::findOne($user_id);
         if ($userModel) {
             $model->created_at = time();
             $model->updated_at = time();
             $model->user_id = $userModel->id;
             if ($model->save()) {
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     }
     return $this->render('create', ['model' => $model]);
 }