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

'134'

上级 06e05d51
......@@ -58,30 +58,35 @@ class IndexController extends Controller
//产品页面
public function product(Request $request)
{
$params = $request->only('search','type','sort','province');
//$params = $request->only(['search','type'=>'']);
//dd($params);
$pid = 9;
$cates = Cate::where('id',$pid)->first();
$node_type = DB::table('node_type')->orderBy('id','asc')->get();
$node_sort = DB::table('node_sort')->orderBy('id','asc')->get();
$pack = new Pack;
$type = '';
$sort = '';
// if(!empty($_GET)){
if($request->type && $request->sort){
$type = $request->type;
$sort = $request->sort;
if(!empty($params['type']) && !empty($params['sort'])){
$type = $params['type'];
$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);
}elseif($request->sort){
}elseif(!empty($params['sort'])){
// print_r($request->sort);exit;
$sort = $request->sort;
$sort = $params['sort'];
// print_r($city);exit;
// 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);
}elseif($request->type){
}elseif(!empty($params['type'])){
// print_r($request->sort);exit;
$type = $request->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);
}elseif($request->search){
}elseif(!empty($params['search'])){
// print_r($request->sort);exit;
$title = $request->search;
$title = $params['search'];
$packs = $pack->where('title',$title )->orWhere('title','like','%'.$title.'%')->orderBy('add_time','desc')->paginate(15);
}else{
$packs = $pack->select('img','title','id','label')->orderBy('add_time','desc')->paginate(6);
......@@ -90,14 +95,16 @@ class IndexController extends Controller
// echo '111';exit;
// $packs = $pack->select('img','title','id','label')->paginate(6);
// }
if(!$request->province){
if(empty($params['province'])){
$province=' ';
}else{
$province = $params['province'];
}
if(!$request->type){
if(!empty($params['type'])){
$type='0';
}
if(!$request->sort){
if(!empty($params['sort'])){
$sort='0';
}
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]);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论