CpService.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * ${CARET}
  4. * @file:CpService.php
  5. * @Created by gnitif
  6. * @Date: 2023/3/21
  7. * @Time: 20:24
  8. */
  9. namespace Modules\CpManage\Services\CpManage;
  10. use Illuminate\Contracts\Pagination\LengthAwarePaginator;
  11. use Illuminate\Support\Facades\DB;
  12. use Modules\CpManage\Models\Cp\Cps;
  13. class CpService
  14. {
  15. public static function selectOptions($cpName = "")
  16. {
  17. $list = Cps::select('cp_id','cp_name','cp_nick','cp_company');
  18. if (!empty($cpName)){
  19. $list->where('cp_name','like',"%{$cpName}%");
  20. }
  21. return $list->get();
  22. }
  23. /**
  24. * 查询产品列表
  25. * name: getCpList
  26. * @param $where
  27. * @param int $pageSize
  28. * @return LengthAwarePaginator
  29. * date 2023/03/22 20:49
  30. */
  31. public static function getCpList($where , int $pageSize = 20)
  32. {
  33. $list = DB::table('cps')->where($where)->orderBy('cp_id','desc')->paginate($pageSize);
  34. if(!$list->isEmpty()){
  35. foreach ($list as $value){
  36. $value->book_count = 0;
  37. }
  38. }
  39. return $list;
  40. }
  41. }