123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <?php
- /**
- * Created by PhpStorm.
- * User: wuzhenke
- * Date: 2019/1/17
- * Time: 16:19
- */
- namespace App\Http\Controllers\Mobile\Active;
- use App\Http\Controllers\Mobile\MobileBaseController;
- use App\Services\Common\CategoryService;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\DB;
- class DeformityController extends MobileBaseController
- {
- protected $categoryService;
- public function __construct(CategoryService $categoryService)
- {
- $this->categoryService = $categoryService;
- }
- public function index(Request $request)
- {
- //获取分类
- $filter_where = [
- 'AIX_education' => 100,
- 'AIX_experience' => 100,
- ];
- $categories = $this->categoryService->getCategories($filter_where); //过滤条件信息
- $categories_res = [];
- foreach ($categories['AIX_education'] as $k => $v) {
- if ($k >= 69) {
- $categories_res['AIX_education'][$k] = $v;
- }
- }
- foreach ($categories['AIX_experience'] as $k => $v) {
- if ($k < 76) {
- $categories_res['AIX_experience'][$k] = $v;
- }
- }
- //获取数据
- $where = $this->_dealWhere($request);
- $list = DB::table('jobs')->where($where)->orderBy('updated_at', 'desc')->paginate(10);
- //数据处理
- foreach ($list as $val) {
- $val->wage_cn = $val->wage_min . '-' . $val->wage_max . '/月';
- $val->education_cn = $val->education ? get_category($val->education) : '不限';
- $val->experience_cn = $val->experience ? get_category($val->experience) : '不限';
- $val->category_cn = get_job_category_cn($val->category);
- $val->district_cn = get_district_cn($val->district);
- }
- //ajax返回
- if ($request->ajax()) {
- if ($list->lastPage() < $list->currentPage()) {
- return response()->json(['status' => 0]);
- }
- return response()->json(['status' => 1, 'data' => view('mobile.app.active.ajax.deformity_list', ['list' => $list->items()])->render()]);
- }
- $return_data['categories'] = $categories_res;
- $return_data['params'] = $request->input();
- $return_data['list'] = $list->items();
- $return_data['wap_title'] = '残疾人就业专区';
- $return_data['user'] = $this->getUser();
- return view('mobile.app.active.deformity', $return_data);
- }
- /**
- * 搜索条件处理
- */
- private function _dealWhere(Request $request)
- {
- //搜索条件
- $where = [];
- $where[] = ['is_deformity', '=', 1];
- $where[] = ['valid', '=', 1];
- $where[] = ['display', '=', 1];
- //审核状态过滤
- if (config('aix.companyset.comset.show_set.jobs_display') == 1) {
- $where[] = ['audit', '=', 1];
- } else {
- $where[] = ['audit', '<>', 3];
- }
- $keyword = $request->input('keyword');
- if (!empty($keyword)) {
- $key_name = $request->input('key_name');
- $where[] = [$key_name, 'like', "%{$keyword}%"];
- }
- $education = $request->input('education');
- if (!empty($education)) {
- $where[] = ['education', '>=', $education];
- }
- $experience = $request->input('experience');
- if (!empty($experience)) {
- $where[] = ['experience', '=', $experience];
- }
- return $where;
- }
- public function getUser()
- {
- $user = array();
- if (auth('web-member')->check()) {
- $user = auth('web-member')->user();
- } elseif (auth('web-company')->check()) {
- $user = auth('web-company')->user();
- }
- return $user;
- }
- }
|