1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php
- namespace common\models;
- class CategoryAlbum extends Common
- {
- public function rules()
- {
- return [
- ['name','required','message'=>'不能为空'],
- ];
- }
- public function FindById($id)
- {
- return self::findOne($id);
- }
- public function getList($input,$select = null)
- {
- $query = $this->FindQuery();
- $query->select($select);
- $query = $this->WhereFocus($query);
- if(!empty($input['page']))
- {
- $query->limit = $input['limit'];
- $query->offset = ($input['page']-1 )* $input['limit'];
- }
- return $query->orderBy(['sort'=>SORT_DESC])->asArray()->all();
- }
- public function Total()
- {
- $query = $this->FindQuery();
- return $this->WhereFocus($query)->count();
- }
- private function FindQuery()
- {
- return self::find();
- }
- private function WhereFocus($query)
- {
- $query->andFilterWhere(['name'=>$this->name]);
- $query->andWhere(['del'=>1]);
- return $query;
- }
- }
|