MemberHandselRepository.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\MembersHandsel;
  4. use Prettus\Repository\Eloquent\BaseRepository;
  5. use Prettus\Repository\Criteria\RequestCriteria;
  6. /**
  7. * Class MemberRepositoryEloquent.
  8. *
  9. * @package namespace App\Repositories;
  10. */
  11. class MemberHandselRepository extends BaseRepository
  12. {
  13. /**
  14. * Specify Model class name
  15. *
  16. * @return string
  17. */
  18. public function model()
  19. {
  20. return MembersHandsel::class;
  21. }
  22. /**
  23. * Boot up the repository, pushing criteria
  24. */
  25. public function boot()
  26. {
  27. $this->pushCriteria(app(RequestCriteria::class));
  28. }
  29. public function addNew($data)
  30. {
  31. return $this->model->create($data);
  32. }
  33. /**积分操作明细
  34. * @param $uid
  35. * @param $utype
  36. * @return mixed
  37. */
  38. public function getMembersHandsel($uid, $utype, $type)
  39. {
  40. $where['uid'] = $uid;
  41. $where['utype'] = $utype;
  42. if ($type != 3) {
  43. $where['operate'] = $type;
  44. }
  45. return $this->model->where($where)->orderBy('created_at', 'desc')->paginate(10, ['*']);
  46. }
  47. public function getNum($user, $type = 1)
  48. {
  49. $where['uid'] = $user->id;
  50. $where['utype'] = $user->utype;
  51. $where['operate'] = $type;
  52. return $this->model->where($where)->selectRaw('sum(points)as getTotalPoints')->get();
  53. }
  54. }