MultiWhere.php 840 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * User: Mike
  4. * Email: m@9026.com
  5. * Date: 2017/1/12
  6. * Time: 17:52
  7. */
  8. namespace App\Repositories\Base\Criteria;
  9. use App\Repositories\Base\Criteria;
  10. use App\Repositories\Contracts\RepositoryInterface as Repository;
  11. class MultiWhere extends Criteria
  12. {
  13. private $search = [];
  14. /**
  15. * MultiWhere constructor.
  16. * @param array $search
  17. *
  18. */
  19. public function __construct(array $search)
  20. {
  21. $this->search = $search;
  22. }
  23. /**
  24. * @param $model
  25. * @param RepositoryInterface $repository
  26. * @return mixed
  27. */
  28. public function apply($model, Repository $repository)
  29. {
  30. if (isset($this->search['deleted_at']) && $this->search['deleted_at']) {
  31. $model = $model->where('deleted_at', $this->search['deleted_at']);
  32. }
  33. return $model;
  34. }
  35. }