JobfairJobRepository.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/22
  6. * Time: 15:42
  7. */
  8. namespace App\Repositories\Jobfair;
  9. use App\Models\Jobfair\JobfairJob;
  10. use Prettus\Repository\Criteria\RequestCriteria;
  11. use Prettus\Repository\Eloquent\BaseRepository;
  12. class JobfairJobRepository extends BaseRepository
  13. {
  14. public function model()
  15. {
  16. return JobfairJob::class;
  17. }
  18. public function boot()
  19. {
  20. $this->pushCriteria(app(RequestCriteria::class));
  21. }
  22. public function getJobList($where)
  23. {
  24. return $this->model->where($where)->orderByRaw('field(audit,2,1,3)')->orderBy('updated_at', 'desc')->paginate(10);
  25. }
  26. public function editJob($id)
  27. {
  28. return $this->model->with('jobsContact')->where('id', $id)->first();
  29. }
  30. public function store($jobData)
  31. {
  32. return $this->model->create($jobData);
  33. }
  34. public function deleteJobs($where, $ids)
  35. {
  36. return $this->model->where($where)->whereIn('id', $ids)->delete();
  37. }
  38. public function getCount($where)
  39. {
  40. return $this->model ->when(get_subsite_id()>0, function ($query) {
  41. $query->whereHas('company', function ($query) {
  42. $query->where('companys.subsite_id', get_subsite_id());
  43. });
  44. })->where($where)->count();
  45. }
  46. public function displayswitch($id, $display)
  47. {
  48. return $this->model->where('id', $id)->update(['display'=>$display]);
  49. }
  50. /**
  51. * 根据条件删除
  52. * @param $where
  53. * @return mixed
  54. */
  55. public function delJobs($column, $ids)
  56. {
  57. return $this->model->whereIn($column,$ids)->delete();
  58. }
  59. public function getAuditJobList($where)
  60. {
  61. return $this->model->where($where)->orderBy('id', 'desc')->get();
  62. }
  63. public function getJobs($where)
  64. {
  65. return $this->model->where($where)->get();
  66. }
  67. public function getCrmJobs($where, $whereIn = [], $order_by = '', $offset = '', $limit = '')
  68. {
  69. $rst = $this->model->with(['company'])->whereHas('company')->where($where);
  70. if ($whereIn) {
  71. foreach ($whereIn as $k => $v) {
  72. $rst->whereIn($k, $v);
  73. }
  74. }
  75. if ($order_by) {
  76. $rst->orderByRaw($order_by);
  77. }
  78. if ($offset !='' && $limit!='') {
  79. $rst->offset($offset)->limit($limit);
  80. };
  81. return $rst->get();
  82. }
  83. public function getCrmInfo ($where)
  84. {
  85. return $this->model->with(['company','contact'])->where($where)->first();
  86. }
  87. public function getCrmJobCount($where, $where_in = [])
  88. {
  89. $rst = $this->model->whereHas('company')->where($where);
  90. if ($where_in) {
  91. foreach ($where_in as $k => $v) {
  92. $rst->whereIn($k, $v);
  93. }
  94. }
  95. return $rst->count();
  96. }
  97. public function getColumn($where,$column)
  98. {
  99. return $this->model->where($where)->value($column);
  100. }
  101. public function getPluck($where,$column)
  102. {
  103. return $this->model->where($where)->pluck($column);
  104. }
  105. }