/** * Creates a new Article model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Article(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }
public function addAerticle($title, $keywords, $categoryId, $content, $status, $isTop, $description, $pic) { $model = new Article(); $model->title = $title; $model->keywords = $keywords; $model->categoryId = $categoryId; $model->content = $content; $model->status = $status; $model->isTop = $isTop; $model->description = $description; $model->pic = $pic; $model->source = '0'; $model->author = Yii::$app->session->get(Variable::$session_userId_str); $model->addTime = date('Y-m-d H:i:s', time()); $model->publishTime = date('Y-m-d H:i:s', time()); $model->addUser = Yii::$app->session->get(Variable::$session_userId_str); if ($model->save()) { return true; } return false; }