ViewJobRepository.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace App\Repositories;
  3. use App\Models\ViewJob;
  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 ViewJobRepository extends BaseRepository
  12. {
  13. /**
  14. * Specify Model class name
  15. *
  16. * @return string
  17. */
  18. public function model()
  19. {
  20. return ViewJob::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 attentionJobs($settr, $where)
  30. {
  31. return $this->model->with(['jobs'=>function($query) use($where) {
  32. $query->whereIn('audit', $where)->where('display', 1)->where('valid', 1);
  33. }])->whereDoesntHave('personSCompany')->where($settr)->orderBy('id', 'desc')->paginate(10);
  34. }
  35. public function delAttentionJobs($id)
  36. {
  37. return $this->model->whereIn('id', $id)->delete();
  38. }
  39. public function getLog($where, $limit = '')
  40. {
  41. if ($limit) {
  42. if ($limit == '1') {
  43. $list = $this->model->where($where)->orderBy('id', 'desc')->first();
  44. } else {
  45. $list = $this->model->where($where)->orderBy('id', 'desc')->limit($limit)->get();
  46. }
  47. } else {
  48. $list = $this->model->where($where)->get();
  49. }
  50. return $list;
  51. }
  52. public function update(array $data, $where)
  53. {
  54. return $this->model->where($where)->update($data);
  55. }
  56. public function addLog($data)
  57. {
  58. return $this->model->create($data);
  59. }
  60. /**谁看过我
  61. * @param $map
  62. * @param $page
  63. * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
  64. */
  65. public function browseJobs($map, $page, $company_id)
  66. {
  67. return $this->model->with('resumes')->where($map)->whereDoesntHave('personSCompany',function ($query) use ($company_id){
  68. $query->where('company_id', $company_id);
  69. })->orderBy('created_at', 'desc')->paginate($page, ['*']);
  70. }
  71. /**谁看过我count
  72. * @param $map
  73. * @return mixed
  74. */
  75. public function browseJobsCount($map)
  76. {
  77. return $this->model->where($map)->count();
  78. }
  79. /**删除谁看过我
  80. * @param $ids
  81. * @param $company_id
  82. * @return mixed
  83. */
  84. public function browseJobsDel($ids,$company_id)
  85. {
  86. return $this->model->whereIn('id', $ids)->where("company_id",$company_id)->delete();
  87. }
  88. }