71 lines
1.7 KiB
PHP
71 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
|
|
namespace app\modules\admin\models\ball;
|
|
|
|
use app\models\BallMark;
|
|
use app\modules\admin\models\AdminModel;
|
|
use yii\data\Pagination;
|
|
|
|
class BallMarkForm extends AdminModel
|
|
{
|
|
public $page;
|
|
public $limit;
|
|
|
|
public $keywords;
|
|
public $status;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['keywords',], 'trim'],
|
|
[['keywords',], 'string'],
|
|
[['page', 'limit', 'status'], 'integer'],
|
|
[['page'], 'default', 'value' => 1],
|
|
[['limit'], 'default', 'value' => 20],
|
|
];
|
|
}
|
|
|
|
public function search()
|
|
{
|
|
if (!$this->validate()) {
|
|
return $this->getModelError();
|
|
}
|
|
$query = BallMark::find()
|
|
->select('id,name,created_at,status')
|
|
->where([
|
|
'is_delete' => 0
|
|
])
|
|
->andFilterWhere([
|
|
'OR',
|
|
['like', 'name', $this->keywords],
|
|
])->andFilterWhere([
|
|
'status' => $this->status
|
|
]);
|
|
|
|
$count = $query->count();
|
|
$pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]);
|
|
$list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['created_at' => SORT_DESC])->asArray()->all();
|
|
$data = [];
|
|
|
|
foreach ($list as $key => $value) {
|
|
$list[$key]['created_at'] = date('Y-m-d H:i:s', $value['created_at']);
|
|
}
|
|
|
|
$data['code'] = 0;
|
|
$data['msg'] = 'ok';
|
|
$data['data'] = $list;
|
|
$data['count'] = $count;
|
|
return $data;
|
|
|
|
}
|
|
} |