public function actionDetail($id)
 {
     $postModel = new Comment();
     if ($postModel->load(Yii::$app->request->post())) {
         $postModel->status = Comment::STATUS_INACTIVE;
         $postModel->post_id = $id;
         if ($postModel->save()) {
             $this->added = 1;
         }
     }
     $tags = Tag::findTagWeights();
     $cateModel = new Cate();
     $cateDataProvider = $cateModel->getCates();
     $postData = new Post();
     $postDataProvider = $postData->findRecentPosts();
     $commentModel = new Comment();
     $commentDataProvider = $commentModel->findRecentComments();
     return $this->render('detail', ['tags' => $tags, 'added' => $this->added, 'postModel' => $postModel, 'model' => $this->findModel($id), 'postDataProvider' => $postDataProvider, 'cateDataProvider' => $cateDataProvider, 'commentDataProvider' => $commentDataProvider]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cate::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias]);
     return $dataProvider;
 }
Beispiel #3
0
 public static function getCates()
 {
     $models = Cate::find()->all();
     return $models;
 }
Beispiel #4
0
 public function getCate()
 {
     return $this->hasOne(Cate::className(), ['id' => 'cate_id']);
 }
 /**
  * Finds the Cate model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cate the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cate::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #6
0
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'content')->widget('kucha\\ueditor\\UEditor', []);
?>

    <?php 
echo $form->field($model, 'tags')->textInput();
?>

    <?php 
echo $form->field($model, 'cate_id')->dropDownList(Cate::getAllCate());
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(Status::labels());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? '发 布' : '修 改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>