DeformityController.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: wuzhenke
  5. * Date: 2019/1/17
  6. * Time: 16:19
  7. */
  8. namespace App\Http\Controllers\Mobile\Active;
  9. use App\Http\Controllers\Mobile\MobileBaseController;
  10. use App\Services\Common\CategoryService;
  11. use Illuminate\Http\Request;
  12. use Illuminate\Support\Facades\DB;
  13. class DeformityController extends MobileBaseController
  14. {
  15. protected $categoryService;
  16. public function __construct(CategoryService $categoryService)
  17. {
  18. $this->categoryService = $categoryService;
  19. }
  20. public function index(Request $request)
  21. {
  22. //获取分类
  23. $filter_where = [
  24. 'AIX_education' => 100,
  25. 'AIX_experience' => 100,
  26. ];
  27. $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
  28. $categories_res = [];
  29. foreach ($categories['AIX_education'] as $k => $v) {
  30. if ($k >= 69) {
  31. $categories_res['AIX_education'][$k] = $v;
  32. }
  33. }
  34. foreach ($categories['AIX_experience'] as $k => $v) {
  35. if ($k < 76) {
  36. $categories_res['AIX_experience'][$k] = $v;
  37. }
  38. }
  39. //获取数据
  40. $where = $this->_dealWhere($request);
  41. $list = DB::table('jobs')->where($where)->orderBy('updated_at', 'desc')->paginate(10);
  42. //数据处理
  43. foreach ($list as $val) {
  44. $val->wage_cn = $val->wage_min . '-' . $val->wage_max . '/月';
  45. $val->education_cn = $val->education ? get_category($val->education) : '不限';
  46. $val->experience_cn = $val->experience ? get_category($val->experience) : '不限';
  47. $val->category_cn = get_job_category_cn($val->category);
  48. $val->district_cn = get_district_cn($val->district);
  49. }
  50. //ajax返回
  51. if ($request->ajax()) {
  52. if ($list->lastPage() < $list->currentPage()) {
  53. return response()->json(['status' => 0]);
  54. }
  55. return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.deformity_list', ['list' => $list->items()])->render()]);
  56. }
  57. $return_data['categories'] = $categories_res;
  58. $return_data['params'] = $request->input();
  59. $return_data['list'] = $list->items();
  60. $return_data['wap_title'] = '残疾人就业专区';
  61. $return_data['user'] = $this->getUser();
  62. return view('mobile.app.active.deformity', $return_data);
  63. }
  64. /**
  65. * 搜索条件处理
  66. */
  67. private function _dealWhere(Request $request)
  68. {
  69. //搜索条件
  70. $where = [];
  71. $where[] = ['is_deformity', '=', 1];
  72. $where[] = ['valid', '=', 1];
  73. $where[] = ['display', '=', 1];
  74. //审核状态过滤
  75. if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
  76. $where[] = ['audit', '=', 1];
  77. } else {
  78. $where[] = ['audit', '<>', 3];
  79. }
  80. $keyword = $request->input('keyword');
  81. if (!empty($keyword)) {
  82. $key_name = $request->input('key_name');
  83. $where[] = [$key_name, 'like', "%{$keyword}%"];
  84. }
  85. $education = $request->input('education');
  86. if (!empty($education)) {
  87. $where[] = ['education', '>=', $education];
  88. }
  89. $experience = $request->input('experience');
  90. if (!empty($experience)) {
  91. $where[] = ['experience', '=', $experience];
  92. }
  93. return $where;
  94. }
  95. public function getUser()
  96. {
  97. $user = array();
  98. if (auth('web-member')->check()) {
  99. $user = auth('web-member')->user();
  100. } elseif (auth('web-company')->check()) {
  101. $user = auth('web-company')->user();
  102. }
  103. return $user;
  104. }
  105. }