Ejemplo n.º 1
0
 public function actionUnsubscribe()
 {
     $this->layout = 'unsubscribe-blank';
     $model = new Subscribers();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($subscriber = Subscribers::find()->where(['email' => $model->email, 'isSubscribed' => '1'])->one()) {
             $subscriber->isSubscribed = '0';
             if ($subscriber->update()) {
                 Yii::$app->session->setFlash('success', 'Подписка отменена');
             }
         } else {
             Yii::$app->session->setFlash('error', 'Вы не подписаны на рассылку');
         }
         return $this->refresh();
     } else {
         return $this->render('unsubscribe', ['model' => $model]);
     }
 }
 /**
  * Lists all Subscribers models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Subscribers::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }