| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | 
							- <?php
 
- namespace App\Services\Content;
 
- use App\Models\Feature;
 
- use App\Models\membersProject;
 
- use App\Models\PolicyCategory;
 
- use App\Repositories\CategoryRepository;
 
- use App\Repositories\PolicyCategoryRepository;
 
- use App\Repositories\PolicyPropertyReoository;
 
- use App\Repositories\PolicyRepository;
 
- use Illuminate\Http\Request;
 
- use Illuminate\Support\Facades\DB;
 
- class PolicyService
 
- {
 
-     protected $policyCategoryRepository;
 
-     protected $policyRepository;
 
-     protected $policyPropertyReoository;
 
-     protected $CategoryRepository;
 
-     public function __construct(PolicyCategoryRepository $policyCategoryRepository,PolicyRepository $policyRepository,PolicyPropertyReoository $policyPropertyReoository,CategoryRepository $CategoryRepository)
 
-     {
 
-         $this->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 = '<span style='.$style.'>'.$v->title.'</span>';
 
-                 }
 
-             }
 
-         }
 
-         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()];
 
-         }
 
-     }
 
- }
 
 
  |