CompanyDownResumeRepository.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\CompanyDownResume;
  4. use Illuminate\Support\Facades\DB;
  5. use Prettus\Repository\Eloquent\BaseRepository;
  6. use Prettus\Repository\Criteria\RequestCriteria;
  7. /**
  8. * Class MemberRepositoryEloquent.
  9. *
  10. * @package namespace App\Repositories;
  11. */
  12. class CompanyDownResumeRepository extends BaseRepository
  13. {
  14. /**
  15. * Specify Model class name
  16. *
  17. * @return string
  18. */
  19. public function model()
  20. {
  21. return CompanyDownResume::class;
  22. }
  23. /**
  24. * Boot up the repository, pushing criteria
  25. */
  26. public function boot()
  27. {
  28. $this->pushCriteria(app(RequestCriteria::class));
  29. }
  30. public function getDownResume($data)
  31. {
  32. return $this->model->where($data)->first();
  33. }
  34. public function resumeDownDel($ids, $where)
  35. {
  36. return $this->model->where($where)->whereIn('id', $ids)->delete();
  37. }
  38. /**下载简历列表
  39. * @param $where
  40. * @param $map
  41. * @param $page
  42. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  43. */
  44. public function downResume($where, $map, $page)
  45. {
  46. return $this->model->with('resumes')->where($map)->where($where)->orderBy("is_reply", "asc")->orderBy('down_addtime', 'desc')->paginate($page, ['*']);
  47. }
  48. /**获取简历ID
  49. * @param $id
  50. * @return mixed
  51. */
  52. public function getResumeId($id)
  53. {
  54. return $this->model->whereIn('id', $id)->select(['resume_id'])->get()->toArray();
  55. }
  56. /**企业标记简历
  57. * @param $id
  58. * @param $data
  59. * @return mixed
  60. */
  61. public function companyLabelResume($id, $data)
  62. {
  63. return $this->model->where('id', $id)->update($data);
  64. }
  65. //获取已下载简历数量
  66. public function getDownResumeNums($where)
  67. {
  68. return $this->model->where($where)->count();
  69. }
  70. //获取简历下载信息集合
  71. public function getDowmResumes($where, $whereIn = array(), $arr_filed = 'resume_id')
  72. {
  73. $list = array();
  74. if ($whereIn) {
  75. reset($whereIn);
  76. $rst = $this->model->where($where)->whereIn(key($whereIn), $whereIn[key($whereIn)])->get();
  77. } else {
  78. $rst = $this->model->where($where)->get();
  79. }
  80. if ($rst->toArray()) {
  81. foreach ($rst as $k => $v) {
  82. $list[$v->$arr_filed] = $v;
  83. }
  84. }
  85. return $list;
  86. }
  87. public function getStateArr()
  88. {
  89. return $this->model->getStateArr();
  90. }
  91. public function updateData($where, $set_data)
  92. {
  93. return $this->model->where($where)->update($set_data);
  94. }
  95. public function getDownResumes($where = array(), $orderby = array(), $limit = '')
  96. {
  97. /*$rst = $this->model->with('resumes')->where($where);
  98. if ($orderby) {
  99. foreach ($orderby as $k => $v) {
  100. $rst->orderBy($k, $v);
  101. }
  102. }
  103. if ($limit) {
  104. $rst->limit($limit);
  105. }
  106. return $rst->get();*/
  107. $rst = $this->model->with('resumes')->whereHas('subsite_resume', function ($query) { $query->where('subsite_id', get_subsite_id());})->where($where);
  108. if ($orderby) {
  109. foreach ($orderby as $k => $v) {
  110. $rst->orderBy($k, $v);
  111. }
  112. }
  113. if ($limit) {
  114. $rst->limit($limit);
  115. }
  116. return $rst->get();
  117. }
  118. public function getResumeNumGroup($where, $group_by, $subsite_id)
  119. {
  120. return $this->model->where($where)->select(DB::raw('count(id),DATE(created_at)'))->when($subsite_id!=-1, function($query) use($subsite_id) {
  121. $query->whereHas('companys', function ($query) use($subsite_id) {
  122. $query->where(['subsite_id'=>$subsite_id]);
  123. });
  124. })->groupBy($group_by)->get();
  125. }
  126. public function getPluck($where,$column)
  127. {
  128. return $this->model->where($where)->pluck($column);
  129. }
  130. }