'不能为空'], //['name', 'unique', 'targetClass' => 'common\models\Frontend','on'=>['add']], [['pid','sort'],'number'], ['sort','default','value'=>0], ['url','string','min'=>1], ['url','default','value'=>'javascript:;'], ['icon','string','max'=>50], ['width','string','max'=>50], ['function','string','max'=>100], ['status','in', 'range' => [1, 2, 3]], ['del','default','value'=>1], ['function','default','value'=>''], ['pid','default','value'=>0], ]; } public function Authenticator($input) { $this->load($input,''); if(!$this->validate()) return $this->errors; return $this; } public function FindById($id) { return self::findOne($id); } /*更改排序*/ public function GetFindById($id) { return self::findOne($id); } public function OneFind() { $query = self::find(); $query = $this->ManyWhere($query); return $query->one(); } public function MultipleConditionQuery($select = null) { $query = self::find()->select($select); $query = $this->ManyWhere($query); return $query->orderBy(['sort'=>SORT_DESC])->asArray()->all(); } private function ManyWhere($query) { $query->andFilterWhere(['pid'=>$this->pid]); $query->andFilterWhere(['id'=>$this->id]); $query->andFilterWhere(['status'=>$this->status]); // $query->andFilterWhere(['del'=>$this->setDel]); return $query; } public function getList($data,$select = []) { $query = self::find(); $query->andFilterWhere(['del'=>$this->setDel]); $query->select($select); $query->orderBy(['sort'=>SORT_DESC]); if(!empty($data['page'])) { $query->offset = ($data['page'] - 1) * $data['limit']; $query->limit = $data['limit']; } return $query->asArray()->all(); } public function getListTotal() { $query = self::find(); $query->andFilterWhere(['del'=>$this->setDel]); return $query->count(); } public function PidList($id = 0) { $query = self::find(); $query->select(['name as title','id as value','pid','id']); $query->andWhere(['status'=>$this->setDel]); $query->andFilterWhere(['pid'=>$id]); return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all(); } /*20181108 eit*/ public function getNavList($select=null,$type) { $query = self::find(); $query->select($select); $query->andWhere(['status'=>$this->setDel]); $query->andWhere(['del'=>$this->setDel]); $query->andWhere(['type'=>$type]); // $query->andWhere(['position'=>$position]); $query->andWhere(['<>','pid',0]); return $query->orderBy(['sort'=>SORT_DESC])->asArray()->all(); } public function SonList($limit,$select = []) { $query = self::find(); $query->andWhere(['del'=>1]); $query->andWhere(['status'=>1]); $query->andWhere(['pid'=>$this->pid]); $query->select($select); if(empty($limit)) { $query->limit = 10; }else{ $query->limit = $limit; } return $query->orderBy(['sort'=>SORT_DESC])->asArray()->all(); } }