RecruitController.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. ];
  49. if (!empty($params['keyword'])) {
  50. $where[] = ['jobs_name', 'like', '%' . $params['keyword'] . '%'];
  51. }
  52. if (!empty($params['wage'])) {
  53. $where[] = ['wage', '=', $params['wage']];
  54. }
  55. if (!empty($params['experience'])) {
  56. $where[] = ['experience', '=', $params['experience']];
  57. }
  58. if (!empty($params['education'])) {
  59. $where[] = ['education', '=', $params['education']];
  60. }
  61. $list = Jobs::where($where)->orderBy('updated_at', 'desc')->paginate($size);
  62. if ($list->total() > 0) {
  63. $list_items = $this->jobsService->dealjobFilelds($list->items());
  64. } else {
  65. $list_items = [];
  66. }
  67. $mobile_dropload = false;
  68. if ($list->total() > $size) {
  69. $mobile_dropload = true;
  70. }
  71. if ($request->ajax()) {
  72. if ($list->lastPage() < $list->currentPage()) {
  73. return response()->json(['status' => 0]);
  74. }
  75. return response()->json(['status' => 1, 'data' => view('mobile.app.content.jobs.ajax_job_list', ['params' => $params, 'list_items' => $list_items])->render()]);
  76. }
  77. $return_data = [
  78. 'categories' => $categories,
  79. 'list' => $list,
  80. 'list_items' => $list_items,
  81. 'params' => $params,
  82. 'mobile_dropload' => $mobile_dropload,
  83. 'current_url' => \Illuminate\Support\Facades\Request::getRequestUri(),
  84. ];
  85. return view('mobile.app.ic.recruit.list', $return_data);
  86. }
  87. public function will()
  88. {
  89. return view('mobile.app.ic.recruit.will');
  90. }
  91. public function quanji()
  92. {
  93. return view('mobile.app.ic.recruit.quanji');
  94. }
  95. public function show(Request $request)
  96. {
  97. $job_id = $request->input('id');
  98. $job_rst = $this->jobsService->getJobInfo(array('id'=>$job_id)); //获取job信息
  99. if ($job_rst['status'] == 0) {
  100. $back_url = \Illuminate\Support\Facades\URL::previous();
  101. return $this->showMessage($job_rst['error'], $back_url, true, '上一页', '3');
  102. }
  103. $job_info = $job_rst['job'];
  104. $return_data = array(
  105. 'info' => $job_info,
  106. );
  107. return view('mobile.app.ic.recruit.show',$return_data);
  108. }
  109. public function apply()
  110. {
  111. $district = $this->categoryService->getDefaultDistrict();
  112. return view('mobile.app.ic.recruit.apply', [
  113. 'defaultCity' => $district->defaultCity,
  114. ]);
  115. }
  116. }