public function actionMbMemberships()
 {
     $currUser = Yii::$app->user->getIdentity();
     $currMb = MerchantBrand::find()->where(['merchant_brand_id' => $currUser->username])->one();
     $mbFk = $currMb->_id;
     $query = Membership::find()->where(['merchant_brand_fk' => new \MongoId($mbFk)]);
     $searchModel = new MembershipSearch();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MerchantBrand::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 10]]);
     $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(['like', '_id', $this->_id])->andFilterWhere(['like', 'merchant_brand_id', $this->merchant_brand_id])->andFilterWhere(['like', 'merchant_brand_name1', $this->merchant_brand_name1])->andFilterWhere(['like', 'merchant_brand_name2', $this->merchant_brand_name2])->andFilterWhere(['like', 'merchant_brand_tag', $this->merchant_brand_tag])->andFilterWhere(['like', 'merchant_brand_url', $this->merchant_brand_url])->andFilterWhere(['like', 'merchant_brand_official_url', $this->merchant_brand_official_url])->andFilterWhere(['like', 'merchant_brand_email', $this->merchant_brand_email])->andFilterWhere(['like', 'merchant_brand_logo_img', $this->merchant_brand_logo_img])->andFilterWhere(['like', 'merchant_brand_logo_img_mobile', $this->merchant_brand_logo_img_mobile])->andFilterWhere(['like', 'merchant_brand_search_keywords', $this->merchant_brand_search_keywords])->andFilterWhere(['like', 'merchant_brand_create_date', $this->merchant_brand_create_date])->andFilterWhere(['like', 'merchant_brand_create_user_id', $this->merchant_brand_create_user_id])->andFilterWhere(['like', 'merchant_brand_last_update_date', $this->merchant_brand_last_update_date])->andFilterWhere(['like', 'merchant_brand_last_update_user_id', $this->merchant_brand_last_update_user_id])->andFilterWhere(['like', 'merchant_brand_status', $this->merchant_brand_status]);
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * Creates a new Product model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $currUser = Yii::$app->user->getIdentity();
     $currMb = MerchantBrand::find()->where(['merchant_brand_id' => $currUser->username])->one();
     $mbFk = $currMb->_id;
     $model = new Product();
     $model->merchant_brand_fk = $mbFk;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => (string) $model->_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }