ListRepository.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * 通话列表
  4. * @author system
  5. * @version 1.0
  6. * @date 2018-12-18 16:38:51
  7. *
  8. */
  9. namespace App\Repositories\Call;
  10. use App\Repositories\Base\Repository;
  11. class ListRepository extends Repository {
  12. public function model() {
  13. return \App\Models\CallListModel::class;
  14. }
  15. public function searchList(array $search, array $orderby = ['id' => 'desc'])
  16. {
  17. $currentQuery = $this->model;
  18. if (isset($search['keyword']) && !empty($search['keyword'])) {
  19. $keywords = '%'.$search['keyword'].'%';
  20. $currentQuery = $currentQuery->where(function ($query) use ($keywords) {
  21. $query->where('ip','like', $keywords)
  22. ->orWhere('phone','like', $keywords)
  23. ->orWhere('label','like', $keywords);
  24. });
  25. };
  26. if ($orderby && is_array($orderby)) {
  27. foreach ($orderby AS $field => $value) {
  28. $currentQuery = $currentQuery->orderBy($field, $value);
  29. }
  30. };
  31. return $currentQuery;
  32. }
  33. }