/** * Lists all Post models. * @return mixed */ public function actionIndex() { // if(!empty($_POST['selection'])){ // $result = $_POST['selection']; // foreach($result as $v){ // $model = $this->findModel($v); // $model->status = 1; // $model->save(); // µÈ // } // } // // $model = $this->findModel($id); // $model = Model::find()->where('id' => $_POST['selection'])->all(); // if ($model->load(Yii::$app->request->post()) && $model->save()) { // return $this->redirect(['view', 'id' => $model->id]); // } else { // return $this->render('update', [ // 'model' => $model, // ]); $result = Yii::$app->db->createCommand("select * from {{%home_post}}")->queryAll(); // var_dump($result); exit; // } $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); }
public function actionIndex() { $tags = Tag::findTagWeights(); $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $postModel = new Post(); $postDataProvider = $postModel->findRecentPosts(); $cateModel = new Cate(); $cateDataProvider = $cateModel->getCates(); /*print_r($cateDataProvider);exit();*/ $commentModel = new Comment(); $commentDataProvider = $commentModel->findRecentComments(); return $this->render('index', ['tags' => $tags, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'postDataProvider' => $postDataProvider, 'cateDataProvider' => $cateDataProvider, 'commentDataProvider' => $commentDataProvider]); }
/** * Lists all Post models. * @return mixed */ public function actionIndex() { $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (Yii::$app->request->isPost) { $result = Yii::$app->request->post('selection'); foreach ($result as $v) { $model = $this->findModel($v); if (isset($_POST['review']) && $_POST['review'] == 'APPROVED') { $model->explore_status = Post::EXPLORE_STATUS_APPROVED; Yii::$app->getSession()->setFlash('success', '操作审核成功'); } else { $model->explore_status = Post::EXPLORE_STATUS_PENDING; Yii::$app->getSession()->setFlash('success', '下架成功'); } $model->save(); } return $this->redirect(['index']); } return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Lists all Post models. * @return mixed */ public function actionIndex() { $searchModel = new PostSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }