/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = MGoodscat::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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(['id' => $this->id, 'value' => $this->value]); $query->andFilterWhere(['like', 'cat', $this->cat]); return $dataProvider; }
<?php if (Yii::$app->user->isGuest) { $isAdmin = false; $isMember = false; } else { if (Yii::$app->user->identity->role == 1) { $isAdmin = true; $isMember = false; } else { $isAdmin = false; $isMember = true; } } //get goods cat $goodscat = MGoodscat::find()->all(); NavBar::begin(['brandLabel' => empty($about->com_name) ? "" : $about->com_name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]); /* $menuItems = [ ['label' => '首页', 'url' => ['/site/index']], ['label' => '关于', 'url' => ['/site/about']], ['label' => '联系', 'url' => ['/site/contact']], ]; if (Yii::$app->user->isGuest) { $menuItems[] = ['label' => '注册', 'url' => ['/site/signup']]; $menuItems[] = ['label' => '登录', 'url' => ['/site/login']]; } else { //if (Yii::$app->user->identity->role == 1) { $menuItems[] = [
static function getGoodsKindOption($key = null) { $goodscat = MGoodscat::find()->asArray()->all(); foreach ($goodscat as $gc) { $value = $gc['value']; $arr[$value] = "{$gc['cat']}"; } return $key === null ? $arr : (isset($arr[$key]) ? $arr[$key] : ''); }