jobfairoutPutJobRepository.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ZhangHao
  5. * Date: 2019/6/17
  6. * Time: 15:13
  7. */
  8. namespace App\Repositories\Jobfairout;
  9. use App\Models\Jobfairout\JobfairoutPutJob;
  10. use Prettus\Repository\Eloquent\BaseRepository;
  11. class jobfairoutPutJobRepository extends BaseRepository
  12. {
  13. public function model()
  14. {
  15. return JobfairoutPutJob::class;
  16. }
  17. public function getJobfairJob($where)
  18. {
  19. return $this->model->with('jobs')->whereHas('jobs',function ($query){
  20. $query->where('audit',1);
  21. })->where($where)->get();
  22. }
  23. public function getJobsCount($jobfair_id, $comArr)
  24. {
  25. return $this->model->whereHas('jobs',function ($query) use ($comArr){
  26. $query->where('audit',1)->whereIn('company_id', $comArr);
  27. })->where(['jobfair_id'=>$jobfair_id])->count();
  28. }
  29. public function getNeedPerson($jobfair_id)
  30. {
  31. return $this->model->joinJobfairJob()
  32. ->where(['jobfair_jobs.audit'=>1,'jobfairout_put_jobs.jobfair_id' => $jobfair_id])
  33. ->whereHas('jobfair_company',function($query){
  34. $query->where('audit',1);
  35. })
  36. ->selectRaw('sum(jobfair_jobs.amount) as sum')
  37. ->first();
  38. }
  39. //招聘会参展职位
  40. public function jobfairCompanyJob($where,$map1, $limit)
  41. {
  42. return $this->model->with(['jobfair_company','jobfairs','jobs'])->whereHas('jobs',function ($query) use ($map1){
  43. $query->where($map1)->orderByRaw("Field(jobfair_jobs.audit,2,1,3)");
  44. })->where($where)->orderByDesc('created_at')->paginate($limit);
  45. }
  46. public function findDone($where)
  47. {
  48. return $this->model->where($where)->first();
  49. }
  50. public function searchJob($jobfair_id, $keyword, $company_id, $id)
  51. {
  52. return $this->model->whereHas('jobs',function ($query) use ($company_id,$keyword){
  53. $query->where('audit',1)->where('company_id',$company_id)->where(function ($query) use ($keyword){
  54. $query->where('jobs_name', 'like', '%'.$keyword.'%')->orWhere('company_name', 'like', '%'.$keyword.'%');
  55. });
  56. })->where(['jobfair_id'=> $jobfair_id])->where('exid', $id)->get();
  57. }
  58. public function getOne($where)
  59. {
  60. return $this->model->with(['jobfairs','jobs'])->where($where)->first();
  61. }
  62. public function getJobIds($where)
  63. {
  64. return $this->model->whereHas('jobs',function ($query){
  65. $query->where('audit',1);
  66. })->where($where)->pluck('job_id')->toArray();
  67. }
  68. public function destroyArr($del_array)
  69. {
  70. return $this->model->destroy($del_array);
  71. }
  72. public function delList($where,$ids)
  73. {
  74. return $this->model->where($where)->whereIn('job_id',$ids)->delete();
  75. }
  76. //允许预定的招聘会
  77. public function getJobfairOpen()
  78. {
  79. return $this->model->where('predetermined_status', 1)->get();
  80. }
  81. public function getWhere($jobs_where,$put_jobs_where)
  82. {
  83. return $this->model->whereHas('jobs',function ($query) use($jobs_where){
  84. $query->where($jobs_where);
  85. })->where($put_jobs_where)->groupBy('job_id')->get();
  86. }
  87. public function delJobs($id)
  88. {
  89. return $this->model->whereIn('id', $id)->delete();
  90. }
  91. public function getPluck($where,$column)
  92. {
  93. return $this->model->where($where)->pluck($column);
  94. }
  95. }