RecruitController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace App\Http\Controllers\Mobile\Ic;
  3. use App\Http\Controllers\Mobile\MobileBaseController;
  4. use App\Models\Jobs;
  5. use App\Services\Common\CategoryService;
  6. use App\Services\Company\JobsService;
  7. use Illuminate\Http\Request;
  8. class RecruitController extends MobileBaseController
  9. {
  10. protected $categoryService;
  11. protected $jobsService;
  12. /**
  13. * JobsController constructor.
  14. * @param $categoryService
  15. */
  16. public function __construct(CategoryService $categoryService, JobsService $jobsService)
  17. {
  18. $this->categoryService = $categoryService;
  19. $this->jobsService = $jobsService;
  20. }
  21. public function index()
  22. {
  23. return view('mobile.app.ic.recruit.index');
  24. }
  25. public function list(Request $request)
  26. {
  27. //获取分类
  28. $filter_where = [
  29. 'AIX_education' => 100,
  30. 'AIX_experience' => 100,
  31. 'AIX_wage' => 100,
  32. ];
  33. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  34. //默认参数
  35. $param_array = ['keyword', 'wage', 'experience', 'education'];
  36. $params = [];
  37. if ($request->all()) {
  38. foreach ($request->all() as $k => $v) {
  39. if (in_array($k, $param_array) && $v) {
  40. $params[$k] = $v;
  41. }
  42. }
  43. }
  44. //查询条件
  45. $size = 10;
  46. $where = [
  47. ['is_ic', '=', 1],
  48. ['valid', '=', 1],
  49. ['audit', '=', 1],
  50. ['display', '=', 1],
  51. ];
  52. if (!empty($params['keyword'])) {
  53. $where[] = ['jobs_name', 'like', '%' . $params['keyword'] . '%'];
  54. }
  55. if (!empty($params['wage'])) {
  56. $where[] = ['wage', '=', $params['wage']];
  57. }
  58. if (!empty($params['experience'])) {
  59. $where[] = ['experience', '=', $params['experience']];
  60. }
  61. if (!empty($params['education'])) {
  62. $where[] = ['education', '=', $params['education']];
  63. }
  64. $list = Jobs::where($where)->orderBy('updated_at', 'desc')->paginate($size);
  65. if ($list->total() > 0) {
  66. $list_items = $this->jobsService->dealjobFilelds($list->items());
  67. } else {
  68. $list_items = [];
  69. }
  70. $mobile_dropload = false;
  71. if ($list->total() > $size) {
  72. $mobile_dropload = true;
  73. }
  74. if ($request->ajax()) {
  75. if ($list->lastPage() < $list->currentPage()) {
  76. return response()->json(['status' => 0]);
  77. }
  78. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  79. }
  80. $return_data = [
  81. 'categories' => $categories,
  82. 'list' => $list,
  83. 'list_items' => $list_items,
  84. 'params' => $params,
  85. 'mobile_dropload' => $mobile_dropload,
  86. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  87. ];
  88. return view('mobile.app.ic.recruit.list', $return_data);
  89. }
  90. public function will()
  91. {
  92. return view('mobile.app.ic.recruit.will');
  93. }
  94. public function quanji()
  95. {
  96. return view('mobile.app.ic.recruit.quanji');
  97. }
  98. public function show(Request $request)
  99. {
  100. $job_id = $request->input('id');
  101. $job_rst = $this->jobsService->getJobInfo(['id' => $job_id]); //获取job信息
  102. if ($job_rst['status'] == 0) {
  103. $back_url = \Illuminate\Support\Facades\URL::previous();
  104. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  105. }
  106. $job_info = $job_rst['job'];
  107. $return_data = [
  108. 'info' => $job_info,
  109. ];
  110. return view('mobile.app.ic.recruit.show', $return_data);
  111. }
  112. public function apply()
  113. {
  114. $district = $this->categoryService->getDefaultDistrict();
  115. return view('mobile.app.ic.recruit.apply', [
  116. 'defaultCity' => $district->defaultCity,
  117. ]);
  118. }
  119. }