| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | <?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 QuanzhidaController 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('quanzhida')->where($where)->orderBy('wage_max','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) : '不限';        }        //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.quanzhida_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 view('mobile.app.active.quanzhida', $return_data);    }    /**     * 搜索条件处理     */    private function _dealWhere(Request $request)    {        //搜索条件        $where = [];        $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;    }}
 |