UrsPartnerDividendRepository.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Module\UrsPromotion\Repositories;
  3. use App\Module\UrsPromotion\Models\UrsPartnerDividendRecord;
  4. use Illuminate\Database\Eloquent\Model;
  5. /**
  6. * URS合伙人分红仓库类
  7. *
  8. * 仅供后台管理数据访问使用
  9. */
  10. class UrsPartnerDividendRepository
  11. {
  12. /**
  13. * 模型实例
  14. */
  15. protected Model $model;
  16. /**
  17. * 预加载关系
  18. */
  19. protected array $with;
  20. /**
  21. * 构造函数
  22. */
  23. public function __construct(array $with = [])
  24. {
  25. $this->model = new UrsPartnerDividendRecord();
  26. $this->with = array_merge(['transferApp'], $with);
  27. }
  28. /**
  29. * 获取查询构建器
  30. */
  31. public function query()
  32. {
  33. return $this->model->with($this->with);
  34. }
  35. /**
  36. * 根据ID查找记录
  37. */
  38. public function find(int $id): ?UrsPartnerDividendRecord
  39. {
  40. return $this->query()->find($id);
  41. }
  42. /**
  43. * 获取所有记录
  44. */
  45. public function all()
  46. {
  47. return $this->query()->get();
  48. }
  49. /**
  50. * 分页获取记录
  51. */
  52. public function paginate(int $perPage = 15)
  53. {
  54. return $this->query()->paginate($perPage);
  55. }
  56. }