12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace common\models;
- class HousesPrice extends Common
- {
- public function rules()
- {
- return [
- ['price','required','message'=>'价格不能为空'],
- ['price_short','required','message'=>'短标不能为空'],
- ['state','in','range'=>[1,2]],
- ['del','in','range'=>[1,2]],
- ];
- }
- public function FindById($id)
- {
- return self::findOne($id);
- }
- public function getList($input,$arr = null)
- {
- $query = self::find();
- $query->select($arr);
- $query = $this->WhereFouse($query);
- if(!empty($input['page']))
- {
- $query->offset = ($input['page'] -1 ) * $input['limit'];
- $query->limit = $input['limit'];
- }
- return $query->orderBy(['create_at'=>SORT_DESC])->asArray()->all();
- }
- public function WhereFouse($query)
- {
- $query->andFilterWhere(['del'=>$this->setDel]);
- $query->andFilterWhere(['price'=>$this->price]);
- return $query;
- }
- public function Total()
- {
- $query = self::find();
- $query = $this->WhereFouse($query);
- return $query->count();
- }
- }
|