Пример #1
0
 /**
  * Lists all Contact models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ContactSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->setPagination(['pageSize' => 10]);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Пример #2
0
 public function run($id = null)
 {
     if ($id == null) {
         $searchModel = new ContactSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->controller->render('contact', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     } else {
         $model = Contact::findOne($id);
         $model->status = 1;
         $model->save();
         return $this->controller->render('_contact', ['model' => $model]);
     }
 }
 public function actionUpdateStatus($id)
 {
     $this->layout = "admin";
     $model = $this->findModel($id);
     if ($model->status) {
         $model->status = 0;
     } else {
         $model->status = 1;
     }
     $model->save();
     $searchModel = new ContactSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     //return $this->goBack();
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }