ListRepository.php 1000 B

123456789101112131415161718192021222324252627282930313233343536373839
  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)->orWhere('phone','like', $keywords);
  22. });
  23. };
  24. if ($orderby && is_array($orderby)) {
  25. foreach ($orderby AS $field => $value) {
  26. $currentQuery = $currentQuery->orderBy($field, $value);
  27. }
  28. };
  29. return $currentQuery;
  30. }
  31. }