/** * Creates a new Daters model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Daters(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Applyjobs model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Daters(); $data = Yii::$app->request->post(); //var_dump(isset($date['content']); if (!(isset($data['phone']) && isset($data['picture']) && isset($data['sex']) && isset($data['age']) && isset($data['hobbyid']) && isset($data['content']))) { return array('flag' => 0, 'msg' => 'no enough arg!'); } $user = Users::findOne(['phone' => $data['phone']]); if (!$user) { return array('flag' => 0, 'msg' => 'create dater fail!'); } $data['userid'] = $user->id; $data['created_at'] = time(); foreach ($model->activeAttributes() as $item) { $model->{$item} = $data[$item]; } if ($model->save()) { return array('flag' => 1, 'msg' => 'create dater success!'); } else { //var_dump($model->errors); return array('flag' => 0, 'msg' => 'create dater fail!'); } }