JobfairoutCompanyRepository.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ZhangHao
  5. * Date: 2019/6/17
  6. * Time: 11:12
  7. */
  8. namespace App\Repositories\Jobfairout;
  9. use App\Models\Jobfairout\JobfairoutCompany;
  10. use Prettus\Repository\Eloquent\BaseRepository;
  11. class JobfairoutCompanyRepository extends BaseRepository
  12. {
  13. public function model()
  14. {
  15. return JobfairoutCompany::class;
  16. }
  17. public function getComCount($where)
  18. {
  19. return $this->model->where($where)->count();
  20. }
  21. public function findCompany($where, $offset = 0, $limit = 10)
  22. {
  23. return $this->model->with(['jobfairout'=>function ($query) {
  24. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  25. },'companys'])->where($where)->offset($limit*$offset)->limit($limit)->get();
  26. }
  27. public function getComList($where)
  28. {
  29. return $this->model->where($where)->select(['company_id'])->get();
  30. }
  31. public function findCom($where)
  32. {
  33. return $this->model->with(['companys','jobfairPutJob'=>function($query){
  34. $query->with('jobs');
  35. }])->where($where)->first();
  36. }
  37. public function jobfairAppointment($where)
  38. {
  39. return $this->model->where($where)->first();
  40. }
  41. public function findList($where)
  42. {
  43. return $this->model->whereHas('jobfairout')->where($where)->orderby('created_at', 'desc')->paginate(10);
  44. }
  45. public function getJobfair($com_id)
  46. {
  47. return $this->model->with(['jobfairout'=>function ($query) {
  48. $query->where([['holddate_end', '>', time()]]);
  49. }])->whereHas('jobfairout',function ($query){
  50. $query->where([['holddate_end', '>', time()]]);
  51. })->where(['company_id'=>$com_id])->where('audit','<>',3)->get();
  52. }
  53. public function findJob($where)
  54. {
  55. return $this->model->with(['jobfairout'=>function ($query) {
  56. $query->where('showendtime', '>=', time())->orWhere('showendtime', 0);
  57. }])->with('companys')->where($where)->get();
  58. }
  59. public function getCount($where, $subsite_id)
  60. {
  61. return $this->model->when($subsite_id,function ($query) use($subsite_id) {
  62. $query->whereHas('jobfairout', function ($query) use($subsite_id) {
  63. $query->where($subsite_id);
  64. });
  65. })->where($where)->count();
  66. }
  67. public function findListOption($com_id)
  68. {
  69. return $this->model->whereHas('jobfairout')->where(['company_id'=>$com_id])->groupBy('jobfair_id')->orderby('created_at', 'desc')->get();
  70. }
  71. public function getPluck($where,$column)
  72. {
  73. return $this->model->where($where)->pluck($column);
  74. }
  75. public function getValue($where,$column)
  76. {
  77. return $this->model->where($where)->value($column);
  78. }
  79. }