提交 e6c67eb1 authored 作者: 邓奇's avatar 邓奇

123

上级 cfadcc1f
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Account; use App\Models\Account;
use Illuminate\Support\Facades\Cookie; use Illuminate\Support\Facades\Cookie;
use Illuminate\Http\Request; use Illuminate\Http\Request;
...@@ -18,150 +19,157 @@ use App\Models\Payback; ...@@ -18,150 +19,157 @@ use App\Models\Payback;
use Illuminate\Support\Facades\Session; use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use QrCode; use QrCode;
class IndexController extends Controller class IndexController extends Controller
{ {
public function __construct() public function __construct()
{ {
$this->user = new User; $this->user = new User;
$this->url = 'https://renzaoshi.oceano.com.cn/'; $this->url = 'https://renzaoshi.oceano.com.cn/';
$cate = new Cate; $cate = new Cate;
$this->showType=$cate->showType(); $this->showType = $cate->showType();
$this->showType_b=$cate->showType_bottom(); $this->showType_b = $cate->showType_bottom();
} }
//首页 //首页
public function index(Request $request){ public function index(Request $request)
$banner =new Banner; {
$banner = new Banner;
$pack = new Pack; $pack = new Pack;
$content = new Content; $content = new Content;
$cate = new Cate; $cate = new Cate;
$records = $content->where('type',21)->orderBy('add_time','desc')->limit(4)->get();//新闻 $records = $content->where('type', 21)->orderBy('add_time', 'desc')->limit(4)->get();//新闻
$type = 18; $type = 18;
$twoCols=$cate->where("fid",$type)->get()->toArray(); $twoCols = $cate->where("fid", $type)->get()->toArray();
if($twoCols){ if ($twoCols) {
// echo '<pre>'; // echo '<pre>';
foreach ($twoCols as $key => $value) { foreach ($twoCols as $key => $value) {
$id[]=$value['id']; $id[] = $value['id'];
} }
$id[] =$type; $id[] = $type;
} }
$show = $content->where('id',22)->first(); $show = $content->where('id', 22)->first();
$shows = $content->where('type',34)->orderBy('add_time','asc')->paginate(4); $shows = $content->where('type', 34)->orderBy('add_time', 'asc')->paginate(4);
$cases = $content->whereIN('type',$id)->where('isRecommend','1')->orderBy('add_time','desc')->limit(4)->get(); $cases = $content->whereIN('type', $id)->where('isRecommend', '1')->orderBy('add_time', 'desc')->limit(4)->get();
// echo '<pre>'; // echo '<pre>';
// print_r($cases);exit; // print_r($cases);exit;
$packs = $pack->where('is_Hot',1)->select('img','title','id','label')->paginate(10);//产品 $packs = $pack->where('is_Hot', 1)->select('img', 'title', 'id', 'label')->paginate(10);//产品
$banners = $banner->where('isHot','1')->limit(2)->get(); $banners = $banner->where('isHot', '1')->limit(2)->get();
return view('index.index',['banners'=>$banners,'packs'=>$packs,'records'=>$records,'cases'=>$cases,'shows'=>$shows,'show'=>$show,'showType'=>$this->showType,'showType_b'=>$this->showType_b,]); return view('index.index', ['banners' => $banners, 'packs' => $packs, 'records' => $records, 'cases' => $cases, 'shows' => $shows, 'show' => $show, 'showType' => $this->showType, 'showType_b' => $this->showType_b,]);
} }
//产品页面 //产品页面
public function product(Request $request) public function product(Request $request)
{ {
$params = $request->only('search','type','sort','province'); $type = $request->type;
//$params = $request->only(['search','type'=>'']); $sort = $request->sort;
//dd($params); $params = [
'sort' => $sort,
'type' => $type,
];
//$params = $request->all();
$pid = 9; $pid = 9;
$cates = Cate::where('id',$pid)->first(); $cates = Cate::where('id', $pid)->first();
$node_type = DB::table('node_type')->orderBy('id','asc')->get(); $node_type = DB::table('node_type')->orderBy('id', 'asc')->get();
$node_sort = DB::table('node_sort')->orderBy('id','asc')->get(); $node_sort = DB::table('node_sort')->orderBy('id', 'asc')->get();
$pack = new Pack; $pack = new Pack;
$type = ''; $type = '';
$sort = ''; $sort = '';
// if(!empty($_GET)){ // if(!empty($_GET)){
if(!empty($params['type']) && !empty($params['sort'])){ if (!empty($params['type']) && !empty($params['sort'])) {
$type = $params['type']; $type = $params['type'];
$sort = $params['sort']; $sort = $params['sort'];
$packs = DB::table("package")->whereRaw('FIND_IN_SET("'.$type.'",status) and FIND_IN_SET("'.$sort.'",label)')->select('img','title','id','label')->orderBy('add_time','desc')->paginate(6); $packs = DB::table("package")->whereRaw('FIND_IN_SET("' . $type . '",status) and FIND_IN_SET("' . $sort . '",label)')->select('img', 'title', 'id', 'label')->orderBy('add_time', 'desc')->paginate(6);
}elseif(!empty($params['sort'])){ } elseif (!empty($params['sort'])) {
// print_r($request->sort);exit; // print_r($request->sort);exit;
$sort = $params['sort']; $sort = $params['sort'];
// print_r($city);exit; // print_r($city);exit;
// DB::connection()->enableQueryLog();#开启执行日志 // DB::connection()->enableQueryLog();#开启执行日志
$packs = DB::table("package")->whereRaw('FIND_IN_SET("'.$sort.'",label)')->select('img','title','id','label','city')->orderBy('add_time','desc')->paginate(6); $packs = DB::table("package")->whereRaw('FIND_IN_SET("' . $sort . '",label)')->select('img', 'title', 'id', 'label', 'city')->orderBy('add_time', 'desc')->paginate(6);
}elseif(!empty($params['type'])){ } elseif (!empty($params['type'])) {
// print_r($request->sort);exit; // print_r($request->sort);exit;
$type = $params['type']; $type = $params['type'];
$packs = DB::table("package")->whereRaw('FIND_IN_SET("'.$type.'",status)')->select('img','title','id','label','city')->orderBy('add_time','desc')->paginate(6); $packs = DB::table("package")->whereRaw('FIND_IN_SET("' . $type . '",status)')->select('img', 'title', 'id', 'label', 'city')->orderBy('add_time', 'desc')->paginate(6);
}elseif(!empty($params['search'])){ } elseif (!empty($params['search'])) {
// print_r($request->sort);exit; // print_r($request->sort);exit;
$title = $params['search']; $title = $params['search'];
$packs = $pack->where('title',$title )->orWhere('title','like','%'.$title.'%')->orderBy('add_time','desc')->paginate(15); $packs = $pack->where('title', $title)->orWhere('title', 'like', '%' . $title . '%')->orderBy('add_time', 'desc')->paginate(15);
}else{ } else {
$packs = $pack->select('img','title','id','label')->orderBy('add_time','desc')->paginate(6); $packs = $pack->select('img', 'title', 'id', 'label')->orderBy('add_time', 'desc')->paginate(6);
} }
// }else{ // }else{
// echo '111';exit; // echo '111';exit;
// $packs = $pack->select('img','title','id','label')->paginate(6); // $packs = $pack->select('img','title','id','label')->paginate(6);
// } // }
if(empty($params['province'])){ if (empty($params['province'])) {
$province=' '; $province = ' ';
}else{ } else {
$province = $params['province']; $province = $params['province'];
} }
if(!empty($params['type'])){ if (!$params['type']) {
$type='0'; $type = 1;
} }
if(!empty($params['sort'])){ if (!$params['sort']) {
$sort='0'; $sort = 1;
} }
return view('index.product',['packs'=>$packs,'province'=>$province,'cates'=>$cates,'type'=>$type,'sort'=>$sort,'node_type'=>$node_type,'node_sort'=>$node_sort,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.product', ['packs' => $packs, 'province' => $province, 'cates' => $cates, 'type' => $type, 'sort' => $sort, 'node_type' => $node_type, 'node_sort' => $node_sort, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//产品详情页 //产品详情页
public function pro_show(Request $request) public function pro_show(Request $request)
{ {
$pid = 9; $pid = 9;
$cates = Cate::where('id',$pid)->first(); $cates = Cate::where('id', $pid)->first();
$pack = new Pack; $pack = new Pack;
$id = $request->id; $id = $request->id;
$node_type = DB::table('node_type')->orderBy('id','asc')->get(); $node_type = DB::table('node_type')->orderBy('id', 'asc')->get();
$node_sort = DB::table('node_sort')->orderBy('id','asc')->get(); $node_sort = DB::table('node_sort')->orderBy('id', 'asc')->get();
$packs = $pack->where('id',$id)->first(); $packs = $pack->where('id', $id)->first();
if(isset($packs->thumb)){ if (isset($packs->thumb)) {
$packs->thumb = explode(',', $packs->thumb); $packs->thumb = explode(',', $packs->thumb);
} }
if(!$request->type){ if (!$request->type) {
$type='1'; $type = '1';
} }
if(!$request->sort){ if (!$request->sort) {
$sort='1'; $sort = '1';
} }
return view('index.pro_show',['packs'=>$packs,'type'=>$type,'cates'=>$cates,'sort'=>$sort,'node_type'=>$node_type,'node_sort'=>$node_sort,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.pro_show', ['packs' => $packs, 'type' => $type, 'cates' => $cates, 'sort' => $sort, 'node_type' => $node_type, 'node_sort' => $node_sort, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//教程 //教程
public function news(Request $request) public function news(Request $request)
{ {
$id = 21; $id = 21;
$content = new Content; $content = new Content;
$cates = Cate::where('id',$id)->first(); $cates = Cate::where('id', $id)->first();
if($request->search){ if ($request->search) {
$title = $request->search; $title = $request->search;
$records = $content->where('type',$id)->where('title','like','%'.$title.'%')->orderBy('add_time','desc')->paginate(4); $records = $content->where('type', $id)->where('title', 'like', '%' . $title . '%')->orderBy('add_time', 'desc')->paginate(4);
}else{ } else {
$records = $content->where('type',$id)->orderBy('add_time','desc')->paginate(4); $records = $content->where('type', $id)->orderBy('add_time', 'desc')->paginate(4);
} }
return view('index.news',['records'=>$records,'cates'=>$cates,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.news', ['records' => $records, 'cates' => $cates, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//新闻内页 //新闻内页
public function news_show(Request $request) public function news_show(Request $request)
{ {
$nid = 21; $nid = 21;
$content = new Content; $content = new Content;
$id = $request->id; $id = $request->id;
$cates = Cate::where('id',$nid)->first(); $cates = Cate::where('id', $nid)->first();
$frecord = $content->where('type',$nid)->where('id','>',$id)->orderBy('add_time','asc')->first();//下一篇 $frecord = $content->where('type', $nid)->where('id', '>', $id)->orderBy('add_time', 'asc')->first();//下一篇
$erecord = $content->where('type',$nid)->where('id','<',$id)->orderBy('add_time','desc')->first();//上一篇 $erecord = $content->where('type', $nid)->where('id', '<', $id)->orderBy('add_time', 'desc')->first();//上一篇
// print_r($erecord);exit; // print_r($erecord);exit;
$content->where('id',$id)->increment('anum'); $content->where('id', $id)->increment('anum');
$records = $content->where('id',$id)->first(); $records = $content->where('id', $id)->first();
return view('index.news_show',['records'=>$records,'cates'=>$cates,'erecord'=>$erecord,'frecord'=>$frecord,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.news_show', ['records' => $records, 'cates' => $cates, 'erecord' => $erecord, 'frecord' => $frecord, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
...@@ -170,29 +178,29 @@ class IndexController extends Controller ...@@ -170,29 +178,29 @@ class IndexController extends Controller
{ {
$id = 34; $id = 34;
$content = new Content; $content = new Content;
$cates = Cate::where('id',$id)->first(); $cates = Cate::where('id', $id)->first();
if($request->search){ if ($request->search) {
$title = $request->search; $title = $request->search;
$records = $content->where('title',$title )->orWhere('title','like','%'.$title.'%')->orderBy('add_time','desc')->paginate(4); $records = $content->where('title', $title)->orWhere('title', 'like', '%' . $title . '%')->orderBy('add_time', 'desc')->paginate(4);
}else{ } else {
$show = $content->where('id',22)->first(); $show = $content->where('id', 22)->first();
$records = $content->where('type',$id)->orderBy('add_time','desc')->paginate(4); $records = $content->where('type', $id)->orderBy('add_time', 'desc')->paginate(4);
} }
return view('index.company',['records'=>$records,'cates'=>$cates,'show'=>$show,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.company', ['records' => $records, 'cates' => $cates, 'show' => $show, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//关于我们 //关于我们
public function about(Request $request) public function about(Request $request)
{ {
$id = 19; $id = 19;
$content = new Content; $content = new Content;
$cates = Cate::where('id',$id)->first(); $cates = Cate::where('id', $id)->first();
$records = $content->where('type',$id)->orderBy('add_time','desc')->first(); $records = $content->where('type', $id)->orderBy('add_time', 'desc')->first();
$node = New Node; $node = New Node;
$arr = $node->where('area','广东')->orderBy('is_hot','desc')->select('address','area','phone','title','pic')->get(); $arr = $node->where('area', '广东')->orderBy('is_hot', 'desc')->select('address', 'area', 'phone', 'title', 'pic')->get();
// print_r($records);exit; // print_r($records);exit;
return view('index.contact_us',['records'=>$records,'cates'=>$cates,'showType'=>$this->showType,'showType_b'=>$this->showType_b,'arr'=>$arr]); return view('index.contact_us', ['records' => $records, 'cates' => $cates, 'showType' => $this->showType, 'showType_b' => $this->showType_b, 'arr' => $arr]);
} }
//视频中心 //视频中心
...@@ -200,46 +208,47 @@ class IndexController extends Controller ...@@ -200,46 +208,47 @@ class IndexController extends Controller
{ {
$id = 20; $id = 20;
$content = new Content; $content = new Content;
$cates = Cate::where('id',$id)->first(); $cates = Cate::where('id', $id)->first();
$records = $content->where('type',$id)->orderBy('add_time','desc')->paginate(6); $records = $content->where('type', $id)->orderBy('add_time', 'desc')->paginate(6);
// print_r($records);exit; // print_r($records);exit;
return view('index.video',['records'=>$records,'cates'=>$cates,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.video', ['records' => $records, 'cates' => $cates, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//视频详情 //视频详情
public function video_show(Request $request) public function video_show(Request $request)
{ {
$content = new Content; $content = new Content;
$id = $request->id; $id = $request->id;
$records = $content->where('id',$id)->first(); $records = $content->where('id', $id)->first();
if($records->video){ if ($records->video) {
$url = $this->url.$records->video; $url = $this->url . $records->video;
}else{ } else {
$url = $records->videourl; $url = $records->videourl;
} }
return view('index.video_show',['records'=>$records,'url'=>$url,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.video_show', ['records' => $records, 'url' => $url, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//案例 //案例
public function case(Request $request) public function case(Request $request)
{ {
$id = 18; $id = 18;
$content = new Content; $content = new Content;
if($request->sid){ if ($request->sid) {
$sid = $request->sid; $sid = $request->sid;
$records = $content->where('type',$sid)->orderBy('add_time','desc')->paginate(15); $records = $content->where('type', $sid)->orderBy('add_time', 'desc')->paginate(15);
}else{ } else {
$cate = new Cate(); $cate = new Cate();
$fid = $cate->where('fid',18)->get()->toArray(); $fid = $cate->where('fid', 18)->get()->toArray();
$cate_id = array_column($fid,'id'); $cate_id = array_column($fid, 'id');
$records = $content->whereIn('type',$cate_id)->orderBy('add_time','desc')->paginate(6); $records = $content->whereIn('type', $cate_id)->orderBy('add_time', 'desc')->paginate(6);
} }
$cates = Cate::where('id',$id)->first(); $cates = Cate::where('id', $id)->first();
$cates_two = Cate::where('fid',$id)->select('id','cate_name')->get(); $cates_two = Cate::where('fid', $id)->select('id', 'cate_name')->get();
if(!$request->sid){ if (!$request->sid) {
$sid='0'; $sid = '0';
} }
return view('index.case',['records'=>$records,'cates'=>$cates,'cates_two'=>$cates_two,'sid'=>$sid,'showType'=>$this->showType,'showType_b'=>$this->showType_b]); return view('index.case', ['records' => $records, 'cates' => $cates, 'cates_two' => $cates_two, 'sid' => $sid, 'showType' => $this->showType, 'showType_b' => $this->showType_b]);
} }
//城市 //城市
...@@ -247,13 +256,13 @@ class IndexController extends Controller ...@@ -247,13 +256,13 @@ class IndexController extends Controller
{ {
$node = New Node; $node = New Node;
$area = $request->area; $area = $request->area;
$records = $node->where('area',$area)->orderBy('addtime','desc')->select('address','area','phone','title','pic')->get(); $records = $node->where('area', $area)->orderBy('addtime', 'desc')->select('address', 'area', 'phone', 'title', 'pic')->get();
if(empty($records)){ if (empty($records)) {
$result = array('msg' => '无数据','code'=>500); $result = array('msg' => '无数据', 'code' => 500);
}else{ } else {
$result = array('msg' => 'success','code'=>200,'records'=>$records); $result = array('msg' => 'success', 'code' => 200, 'records' => $records);
} }
return response()->json($result); return response()->json($result);
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论