OwnerReportService.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Services;
  3. use App\OwnerReport;
  4. use App\Services\common\QueryService;
  5. use Illuminate\Database\Eloquent\Builder;
  6. Class OwnerReportService
  7. {
  8. /**
  9. * @param Builder $builder
  10. * @param array $params
  11. * @return Builder
  12. */
  13. private function query(Builder $builder, array $params)
  14. {
  15. $columnQueryRules = [
  16. 'counting_month_start' => ['alias' => 'counting_month', 'startDate' => '-01'],
  17. 'counting_month_end' => ['alias' => 'counting_month', 'endDate' => '-31'],
  18. 'owner_id' => ['multi' => ','],
  19. ];
  20. return app(QueryService::class)->query($params, $builder, $columnQueryRules,"owner_reports");
  21. }
  22. public function get(array $params, array $withs = null)
  23. {
  24. $query = OwnerReport::query();
  25. if ($withs)$query->with($withs);
  26. return $this->query($query,$params)->get();
  27. }
  28. public function paginate(array $params, array $withs = null)
  29. {
  30. $query = OwnerReport::query();
  31. if ($withs)$query->with($withs);
  32. return $this->query($query,$params)->paginate($params["paginate"] ?? 50);
  33. }
  34. }