DrugReportInfoService.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace App\Services;
  3. use App\Models\DrugReportInfo;
  4. use Illuminate\Support\Arr;
  5. use Illuminate\Support\Facades\DB;
  6. class DrugReportInfoService
  7. {
  8. public function getList(array $filters, string $search, array $sort, int $perPage) {
  9. $options = array_merge([
  10. 'search' => $search,
  11. 'searchable' => DrugReportInfo::$searchable,
  12. ], $sort);
  13. $query = DrugReportInfo::query()
  14. ->applyFilters(
  15. $filters,
  16. $options,
  17. );
  18. return $query->paginate($perPage);
  19. }
  20. /**
  21. * 获取生产企业选项
  22. * @return array
  23. */
  24. public function getProduceEntIdOption(): array
  25. {
  26. return DrugReportInfo::query()
  27. ->where('produce_ent_id', '!=', '')
  28. ->pluck('produce_ent_name', 'produce_ent_id')
  29. ->unique()
  30. ->toArray();
  31. }
  32. /**
  33. * 获取发货企业选项
  34. * @return array
  35. */
  36. public function getFromRefEntIdOption(): array
  37. {
  38. return DrugReportInfo::query()
  39. ->where('from_ref_ent_id', '!=', '')
  40. ->pluck('from_ent_name', 'from_ref_ent_id')
  41. ->unique()
  42. ->toArray();
  43. }
  44. }