policyCategoryRepository = $policyCategoryRepository; $this->policyRepository = $policyRepository; $this->policyPropertyReoository = $policyPropertyReoository; $this->CategoryRepository = $CategoryRepository; } public function getPolicyInfo($id,$fairjob = 0) { $where = array( 'id' => $id, 'is_display'=>'1', ); $policy_info = $this->policyRepository->firstWhere($where); if (empty($policy_info)){ return $policy_info; } if ($policy_info) { $property = $this->policyPropertyReoository->getProperty(['id'=>$policy_info->focos]); $policy_info->property = ''; if ($property) { $policy_info->property = $property->categoryname; } } //获取相同分类下的所有新闻列表 $lists = $this->policy_list('', $policy_info->type_id); $pre_info = array(); $nex_info = array(); $policy_info->prev = 0; $policy_info->next = 0; $info_key = -1; if ($lists->toArray()) { foreach ($lists as $k => $v) { if ($v->id==$id) { $info_key = $k; } } } $prev = $info_key>-1 && !empty($lists[$info_key-1]) ? $lists[$info_key-1] : 0; if ($prev) { $policy_info->prev = 1; $policy_info->prev_title = $prev->origin_title; if($fairjob){ $policy_info->prev_url = route('jobfair.new.show', ['id'=>$prev->id]); }else{ $policy_info->prev_url = route('policy.show', ['id'=>$prev->id]); } } $next = $info_key>-1 && !empty($lists[$info_key+1]) ? $lists[$info_key+1] : 0; if ($next) { $policy_info->next = 1; $policy_info->next_title = $next->origin_title; if($fairjob){ $policy_info->next_url = route('jobfair.new.show', ['id'=>$next->id]); }else{ $policy_info->next_url = route('policy.show', ['id'=>$next->id]); } } return $policy_info; } public function policy_list($key = '', $id = '', $page = '') { $where = array(); $map = array(); $where[] = array('is_display','=','1'); $map[] = array('is_display','=','1'); if ($key) { $where[] = array('title','like','%'.$key.'%'); $map[] = array('title','like','%'.$key.'%'); } if ($id) { $category=PolicyCategory::where(array('id'=>$id))->first(); if($category->parent_id==0){ $where[] = array('parentid','=',$id); }else{ $where[] = array('type_id','=',$id); } $list=$this->policyRepository->getPolicys($where, $page); } else { $or_map = $map; $or_map[] = array('type_id','=','9'); $map[] = array('parentid','=','1'); $list=$this->policyRepository->getAllPolicys($map, $or_map, $page); } if ($list->toArray()) { foreach ($list as $k => $v) { $list[$k]->origin_title = $v->title; $style= ''; if ($v->tit_color) { $style .='color:'.$v->tit_color.';'; } if ($v->tit_b=='1') { $style .='font-weight:bold;'; } if ($style) { $list[$k]->title = ''.$v->title.''; } } } return $list; } public function getChildCategorys($id) { $where = array(); $where['parent_id'] = $id; $list=$this->policyCategoryRepository->getChildCategorys($where); return $list; } //获取指定属性的新闻资讯 public function getFocosPolicys($property_id, $limit = '5') { return $this->policyRepository->getFocosPolicys($property_id, $limit); } public function incrementData($where, $num, $filed) { return $this->policyRepository->incrementData($where, $num, $filed); } //获取人才类型 public function getRCCategory(){ return $this->CategoryRepository->getCategoryByAlias(['alias'=>'RC_category']); } public function getRcInfosByIndex(){ $where[] = ['is_display','=','1']; return Feature::where($where)->orderBy('id', 'desc')->get(); } public function getRcInfos($request){ $page = 10; $where[] = ['is_display','=','1']; if($request->personal){ $where[] = ['personal','=',$request->personal]; } return Feature::where($where)->orderBy('id', 'desc')->paginate($page, ['*']); } public function getTsrcInfos($request){ $page = 10; $where[] = ['is_display','=','1']; $where[] = ['parentid','<>','0']; $where[] = ['type_id','<>','0']; if($request->parentid){ $where[] = ['parentid','=',$request->parentid]; } if($request->type_id){ $where[] = ['type_id','=',$request->type_id]; } return Feature::where($where)->orderBy('id', 'desc')->paginate($page, ['*']); } public function getProInfos($request,$uid){ $page = 10; $where[] = ['uid','=',$uid]; return membersProject::where($where)->orderBy('created_at', 'desc')->paginate($page, ['*']); } public function getProInfo($request){ $where[] = ['id','=',$request['id']]; return membersProject::where($where)->first(); } public function updateProject($data, $user){ DB::beginTransaction(); try { $data['uid']=$user->id; $data['project_audit']=0; if (empty($data['id'])==true) { membersProject::create($data); } else { membersProject::where(['id'=>$data['id']])->update($data); } DB::commit(); return ['code'=>1,'info'=>$data]; } catch (\Exception $e) { DB::rollback(); return ['code'=>0,'info'=>$e->getMessage()]; } } public function delProject($request){ DB::beginTransaction(); try { membersProject::where(['id'=>$request['id']])->delete(); DB::commit(); return ['code'=>1,'info'=>"删除成功"]; } catch (\Exception $e) { DB::rollback(); return ['code'=>0,'info'=>$e->getMessage()]; } } }