| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | 
							- <?php
 
- namespace App\Http\Controllers\Api\Soldier;
 
- use App\Http\Controllers\Api\ApiBaseController;
 
- use App\Models\Category;
 
- use App\Models\CategoryJobs;
 
- use App\Models\Company;
 
- use App\Models\Jobs;
 
- use App\Models\JobsContact;
 
- use Illuminate\Http\Request;
 
- class JobController extends ApiBaseController
 
- {
 
-     public function getSoldierJobList(Request $request)
 
-     {
 
-         $page      = $request->input('page', 1);
 
-         $limit     = $request->input('limit', 10);
 
-         $update_at = $request->input('update_at', '');
 
-         $where = [
 
-             ['valid', '=', 1],
 
-             ['company_audit', '=', 1],
 
-             ['audit', '=', 1],
 
-             ['display', '=', 1],
 
-             ['is_soldier', '=', 1],
 
-         ];
 
-         if (!empty($update_at)) {
 
-             $where[] = ['updated_at', '>', $update_at];
 
-         }
 
-         $list = Jobs::select('id', 'company_id', 'jobs_name', 'company_name', 'nature', 'sex', 'age', 'amount', 'topclass', 'category', 'subclass', 'trade', 'scale', 'tag', 'education', 'experience', 'wage', 'wage_max', 'negotiable', 'wage_min', 'wage_str', 'jobs_content', 'department', 'created_at', 'updated_at')
 
-             ->where($where)
 
-             ->offset(($page - 1) * $limit)
 
-             ->limit($limit)
 
-             ->get()
 
-             ->toArray();
 
-         $ids          = [];
 
-         $category     = [];
 
-         $category_job = [];
 
-         $tag          = [];
 
-         $company_ids  = [];
 
-         foreach ($list as $v) {
 
-             $ids[]          = $v['id'];
 
-             $category[]     = $v['nature'];
 
-             $category_job[] = $v['topclass'];
 
-             $category_job[] = $v['category'];
 
-             $category_job[] = $v['subclass'];
 
-             $category[]     = $v['trade'];
 
-             $category[]     = $v['scale'];
 
-             if (!empty($v['tag'][0])) {
 
-                 $tag = array_merge($tag, $v['tag']);
 
-             }
 
-             $category[]    = $v['education'];
 
-             $category[]    = $v['experience'];
 
-             $company_ids[] = $v['company_id'];
 
-         }
 
-         $category          = array_merge($category, $tag);
 
-         $contact_list      = JobsContact::select('job_id', 'contact', 'telephone', 'email', 'address')->whereIn('job_id', $ids)->get()->keyBy('job_id')->toArray();
 
-         $company_list      = Company::select('id', 'district_cn', 'address', 'map_x', 'map_y', 'nature')->whereIn('id', $company_ids)->get()->keyBy('id')->toArray();
 
-         $nature_ids        = array_column($company_list, 'nature');
 
-         $category          = array_merge($category, $nature_ids);
 
-         $category_list     = Category::whereIn('id', array_unique($category))->pluck('demand', 'id')->toArray();
 
-         $category_job_list = CategoryJobs::whereIn('id', array_unique($category_job))->pluck('name', 'id')->toArray();
 
-         foreach ($list as $k => $v) {
 
-             $list[$k]['contact_name']      = $contact_list[$v['id']]['contact'];
 
-             $list[$k]['contact_telephone'] = $contact_list[$v['id']]['telephone'];
 
-             $list[$k]['contact_email']     = $contact_list[$v['id']]['email'];
 
-             $list[$k]['contact_address']   = $contact_list[$v['id']]['address'];
 
-             $list[$k]['nature']            = empty($category_list[$v['nature']]) ? '' : $category_list[$v['nature']];
 
-             $list[$k]['topclass']          = empty($category_job_list[$v['topclass']]) ? '' : $category_job_list[$v['topclass']];
 
-             $list[$k]['category']          = empty($category_job_list[$v['category']]) ? '' : $category_job_list[$v['category']];
 
-             $list[$k]['subclass']          = empty($category_job_list[$v['subclass']]) ? '' : $category_job_list[$v['subclass']];
 
-             $list[$k]['trade']             = empty($category_list[$v['trade']]) ? '' : $category_list[$v['trade']];
 
-             $list[$k]['scale']             = empty($category_list[$v['scale']]) ? '' : $category_list[$v['scale']];
 
-             $list[$k]['company_nature']    = empty($category_list[$company_list[$v['company_id']]['nature']]) ? '' : $category_list[$company_list[$v['company_id']]['nature']];
 
-             $list[$k]['company_district']  = $company_list[$v['company_id']]['district_cn'];
 
-             $list[$k]['company_address']   = $company_list[$v['company_id']]['address'];
 
-             $list[$k]['company_map_x']     = $company_list[$v['company_id']]['map_x'];
 
-             $list[$k]['company_map_y']     = $company_list[$v['company_id']]['map_y'];
 
-             $tags = [];
 
-             foreach ($v['tag'] as $tag) {
 
-                 if (!empty($category_list[$tag])) {
 
-                     $tags[] = $category_list[$tag];
 
-                 }
 
-             }
 
-             $list[$k]['tag']        = $tags;
 
-             $list[$k]['education']  = empty($category_list[$v['education']]) ? '' : $category_list[$v['education']];
 
-             $list[$k]['experience'] = empty($category_list[$v['experience']]) ? '' : $category_list[$v['experience']];
 
-         }
 
-         return response()->json($list);
 
-     }
 
-     public function getCategory(Request $request)
 
-     {
 
-         $type = $request->input('type', '');
 
-         $list = [];
 
-         if (!empty($type)) {
 
-             $list = Category::where('alias', $type)->select(['id', 'demand'])->get()->toArray();
 
-         }
 
-         return response()->json($list);
 
-     }
 
- }
 
 
  |