| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace App\Repositories\Criterias;
- use KZ2\Repositories\Contracts\RepositoryInterface;
- use KZ2\Repositories\Criteria\Criteria;
- class ChangeLogCriteria extends Criteria
- {
- private $params = [];
- public function __construct($arams)
- {
- $this->params = $arams;
- }
- public function apply($model, RepositoryInterface $repository)
- {
- if (!empty($this->params['type'])) {
- $model = $model->where('type', $this->params['type']);
- }
- if (!empty($this->params['user_uid'])) {
- $model = $model->where('user_uid', $this->params['user_uid']);
- }
- if (!empty($this->params['way'])) {
- $model = $model->where('way', $this->params['way']);
- }
- if (!empty($this->params['user_uid'])) {
- $model = $model->where('user_uid', $this->params['user_uid']);
- }
- if (!empty($this->params['currency_type'])) {
- $model = $model->where('currency_type', $this->params['currency_type']);
- }
- if (!empty($this->params['username'])) {
- $model = $model->whereHas('oneUser', function ($query) {
- $query->where('nick', 'like', '%'. $this->params['username'] .'%');
- });
- }
- return $model;
- }
- }
|