| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- /**
- * 管理日志后台规则.
- *
- * @author jim <jim458734573@gmail.com>
- * @date 2020-02-05 19:17:55
- */
- declare(strict_types=1);
- namespace App\Repositories\Criterias;
- use Hyperf\Database\Query\Builder;
- use KZ2\Repositories\Contracts\RepositoryInterface;
- use KZ2\Repositories\Criteria\Criteria;
- class ManagerLogPagesCriteria extends Criteria
- {
- private $params = [];
- public function __construct($params = [])
- {
- $this->params = $params;
- }
- /**
- * @param Builder $model
- * @param RepositoryInterface $repository
- * @return mixed|void
- */
- public function apply(
- $model,
- RepositoryInterface $repository
- ) {
- if (!empty($this->params['manager_id'])) {
- $model = $model->where('manager_id', $this->params['manager_id']);
- }
- if (!empty($this->params['username'])) {
- $model = $model->where('username', 'LIKE', '%'. $this->params['username'] .'%');
- }
- if (!empty($this->params['nick'])) {
- $model = $model->where('nick', 'LIKE', '%'. $this->params['nick'] .'%');
- }
- if (!empty($this->params['subject'])) {
- $model = $model->where('subject', 'LIKE', '%'. $this->params['subject'] .'%');
- }
- if (!empty($this->params['module'])) {
- $model = $model->where('module', $this->params['module']);
- }
- if (!empty($this->params['ip'])) {
- $model = $model->where('ip', $this->params['ip']);
- }
- return $model;
- }
- }
|