MessageWhere.php 890 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: 思维定制
  5. * Date: 2018/10/28
  6. * Time: 13:41
  7. */
  8. namespace App\Repositories\Map\Criteria;
  9. use App\Repositories\Base\Criteria;
  10. use App\Repositories\Contracts\RepositoryInterface as Repository;
  11. class MessageWhere 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['keyword']) && $this->search['keyword']) {
  31. $keyword = '%'.$this->search['keyword'].'%';
  32. $model = $model->where([['title','like',$keyword]]);
  33. }
  34. return $model;
  35. }
  36. }