public function actionIndex($shop_domain = '')
 {
     $session = Yii::$app->session;
     if ($shop_domain) {
         if ($store = Store::findOne(['domain' => $shop_domain])) {
             $client = $store->getClient();
             if ($client->validateSignature(Yii::$app->request->get())) {
                 $session->set('shop_domain', $shop_domain);
                 return $this->redirect(['index']);
             } else {
                 throw new UnauthorizedHttpException(__('Error validate signature'));
             }
         } else {
             throw new NotFoundHttpException(__('Shop not found'));
         }
     }
     if ($session->has('shop_domain') && ($store = Store::findOne(['domain' => $session->get('shop_domain')]))) {
         $model = new OptionsForm();
         $model->setStore($store);
         $request = Yii::$app->request;
         if ($request->isPost) {
             $model->load($request->post());
             if ($model->saveOptions()) {
                 $store->touch('updated_at');
                 $store->save();
                 Yii::$app->session->setFlash('success', __('Your changes has been saved successfully.'));
             }
             return $this->redirect(['index']);
         }
         $this->layout = 'widget';
         return $this->render('index', ['store' => $store, 'model' => $model]);
     } else {
         throw new NotFoundHttpException(__('Shop not found'));
     }
 }
 /**
  * Updates an existing Store model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id = null)
 {
     if ($id) {
         $store = $this->findModel($id);
     } else {
         $store = new Store();
     }
     if ($store->load(Yii::$app->request->post()) && $store->save()) {
         Yii::$app->session->setFlash('success', __('Your changes has been saved successfully.'));
         return $this->redirect(['index']);
     } else {
         $model = new OptionsForm();
         $model->setStore($store);
         $request = Yii::$app->request;
         if ($request->isPost) {
             $model->load($request->post());
             if ($model->saveOptions()) {
                 $store->touch('updated_at');
                 $store->save();
                 Yii::$app->session->setFlash('success', __('Your changes has been saved successfully.'));
             }
             return $this->redirect(['update', 'id' => $store->id]);
         }
         return $this->render('update', ['store' => $store, 'model' => $model]);
     }
 }
 public function actionSaveOptions()
 {
     $cOptFrm = new OptionsForm();
     if ($cOptFrm->load(Yii::$app->request->post())) {
         if (!$cOptFrm->saveOptions()) {
             $status = 'ERROR';
             $message = Common::M_DATA_SAVE_FAILED;
         }
     }
     $this->redirect(Url::to('/private-room/index/?id=' . $cOptFrm->id));
 }