| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- /**
- * 管理日志后台规则.
- *
- * @author nj
- * @date 2021-02-05 19:17:55
- */
- namespace App\Repositories\Criterias;
- use Illuminate\Database\Eloquent\Builder;
- use KZ2\Laravel\Repositories\Contracts\RepositoryInterface;
- use KZ2\Laravel\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_uid'])) {
- $model = $model->where('manager_uid', $this->params['manager_uid']);
- }
- 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;
- }
- }
|