1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * User: Mike
- * Email: m@9026.com
- * Date: 2017/1/12
- * Time: 17:52
- */
- namespace App\Repositories\Query\Criteria;
- use App\Repositories\Base\Criteria;
- use App\Repositories\Contracts\RepositoryInterface as Repository;
- class MultiWhere extends Criteria {
- private $search = [];
- /**
- * MultiWhere constructor.
- * @param array $search
- *
- */
- public function __construct(array $search)
- {
- $this->search = $search;
- }
- /**
- * @param $model
- * @param RepositoryInterface $repository
- * @return mixed
- */
- public function apply($model, Repository $repository)
- {
- if(isset($this->search['keyword']) && $this->search['keyword']) {
- $model = $model->where('year',$this->search['keyword'])
- ->orWhere('is_paid','like','%' . $this->search['keyword'] . '%')
- ->orWhere('cnumber','like','%' . $this->search['keyword'] . '%')
- ->orWhere('grade','like','%' . $this->search['keyword'] . '%')
- ->orWhere('code','like','%' . $this->search['keyword'] . '%')
- ->orWhere('mobile','like','%' . $this->search['keyword'] . '%');
- }
- return $model;
- }
- }
|