JobfairPersonSignedRepository.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/25
  6. * Time: 17:54
  7. */
  8. namespace App\Repositories\Jobfair;
  9. use App\Models\Jobfair\JobfairPersonSigned;
  10. use App\Models\MemberInfo;
  11. use Prettus\Repository\Eloquent\BaseRepository;
  12. use Illuminate\Support\Facades\DB;
  13. class JobfairPersonSignedRepository extends BaseRepository
  14. {
  15. public function model()
  16. {
  17. return JobfairPersonSigned::class;
  18. }
  19. public function getSignedInterview($where)
  20. {
  21. return $this->model->with(['resumes'])->whereHas('resumes')->where($where)->orderBy("created_at", 'desc')->paginate(10);
  22. }
  23. public function createInfo($data)
  24. {
  25. return $this->model->create($data);
  26. }
  27. public function getJobfairVisitorNum($where)
  28. {
  29. return $this->model->where($where)->count();
  30. }
  31. public function getStatisticsPersonList($where, $whereIn, $groupBy)
  32. {
  33. $res = $this->model->selectRaw('uid, sex,idcard,jobfairid')->where($where);
  34. if ($whereIn) {
  35. foreach ($whereIn as $k => $v) {
  36. $res->whereIn($k, $v);
  37. }
  38. }
  39. if ($groupBy) {
  40. foreach ($groupBy as $k => $v) {
  41. $res->groupBy($v);
  42. }
  43. }
  44. return $res->orderBy('sex', 'asc')->get();
  45. }
  46. public function getStatisticsPersonEducations($type, $where, $whereIn, $groupBy, $fields, $order_by = '')
  47. {
  48. $s_join_field = $type;
  49. $m_join_field = $type;
  50. if ($type == 'uid') {
  51. $m_join_field = 'uid';
  52. } elseif ($type == 'idcard') {
  53. $m_join_field = 'id_card';
  54. }
  55. $rst = DB::table(JobfairPersonSigned::getTableName().' as s')->select(DB::raw($fields))
  56. ->leftjoin(MemberInfo::getTableName().' as m', 'm.'.$m_join_field, '=', 's.'.$s_join_field)
  57. ->where($where);
  58. if ($whereIn) {
  59. foreach ($whereIn as $k => $v) {
  60. $rst->whereIn($k, $v);
  61. }
  62. }
  63. if ($groupBy) {
  64. foreach ($groupBy as $k => $v) {
  65. $rst->groupBy($v);
  66. }
  67. }
  68. if ($order_by) {
  69. $rst->orderByRaw($order_by);
  70. }
  71. return $rst->get();
  72. }
  73. //获取猜你喜欢
  74. public function likeResumes($where,$jobfair_id)
  75. {
  76. return $this->model->whereHas('resumes',function($query) use ($where){
  77. $query->where($where);
  78. })->where('jobfairid',$jobfair_id)->get();
  79. }
  80. }